March 2019
Intermediate to advanced
208 pages
5h 11m
English
Here’s a definition of a record of the order type and an example of how you access the individual fields using dot notation. You don’t have to specify the fields in the same order that you used when you created the data type:
| | let myOrder = { |
| | quantity: 1, |
| | size: XLarge(1), |
| | sleeve: Long, |
| | color: Blue, |
| | pattern: Solid, |
| | cuff: Button, |
| | collar: Button |
| | }; |
| | |
| | Js.log2("Size:", myOrder.size); /* Size: [1, tag: 1] */ |
This looks a lot like a JavaScript object, but it isn’t one. Let me say that again: ReasonML records are not JavaScript objects. We’ll discuss that when we talk about Interoperating with Objects. One of the biggest differences ...
Read now
Unlock full access