March 2019
Intermediate to advanced
208 pages
5h 11m
English
Arrays are a lot like lists, but there are significant differences. While lists are immutable, arrays can be changed in place. (Whether this is a good idea or not is another question entirely. One school of thought says mutating arrays is a source of errors.) Unlike lists, arrays don’t have a performance penalty for random access.
You define an array by placing the elements, separated by commas, between the delimiters [| and |].
| | let items = [|10, 11, 12, 13, 14, 15, 16|]; |
| | Js.log(items); |
Unlike lists, arrays display quite nicely, but they display square brackets [ and ] rather than the delimiters [| and |] you used when you created the array:
| | you@computer:~/book_projects/collections> node ... |
Read now
Unlock full access