Created
March 25, 2018 04:19
-
-
Save keirah/ec1cd06d210e1557be75b5a7733de832 to your computer and use it in GitHub Desktop.
Accessing the third element - https://reasonml.chat/t/using-json-in-reason-with-belt/360
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[@bs.module] external lab : Js.t({..}) = "./lab.json"; | |
let x = lab##components; | |
let x2 = Belt.List.fromArray(x); | |
/* Js.log2("length using array length: ", Belt.Array.length(x)); */ | |
Js.log2("length using list length: ", Belt.List.length(x2)); | |
Js.log(x2); | |
let third = Belt.List.get(x2, 2); | |
let unwrapThird = someVal => | |
switch someVal { | |
| None => Js.log("nothing here") | |
| Some(value) => Js.log(value) | |
}; | |
unwrapThird(third); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment