From the course: ReasonML: First Look
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Using collection types - ReasonML Tutorial
From the course: ReasonML: First Look
Using collection types
- [Instructor] Up to now, we've been working with individual variables. Reason has three ways to make collections of data. Tuples, which have fixed length and whose items can have different data types, lists, which don't have a fixed length but are immutable and whose elements must all be the same type, and arrays. For our first look, we'll investigate arrays, which are the closest to their JavaScript equivalent. To make an array in Reason, you put the items, separated by commas, between square brackets and vertical bars. Here is an array of integers. In Reason, all the elements in an array must have the same data type. To access an element in the array, you put its index number in square brackets. This will give us 11 because index numbers for an array begin at zero. Using an index number in brackets isn't entirely safe. If the index is out of bounds, your program will throw an exception. A safer way to get elements…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Creating your own data types5m 10s
-
(Locked)
Say goodbye to null and undefined4m 39s
-
(Locked)
Creating modules for reusable code2m 35s
-
(Locked)
Using collection types6m 41s
-
(Locked)
Creating record types6m 47s
-
(Locked)
Challenge: Generating random cakes2m 1s
-
(Locked)
Solution: Generating random cakes2m 57s
-
(Locked)
-
-