Last active
January 13, 2020 00:01
-
-
Save vmarcosp/65d4cd0290f2c17f4b941fcceaee8cbd to your computer and use it in GitHub Desktop.
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
open Belt; | |
let person = Js.Nullable.return({ "name": "marcos"})->Js.Nullable.toOption; | |
person | |
->Option.map(person => person##name) | |
-> Option.getWithDefault(""); | |
let (>=) = (maybe, func) => maybe->Option.map(func); | |
let (>?) = (maybe, defaultValue) => maybe->Option.getWithDefault(defaultValue); | |
let name = person | |
>= (person => person##name) | |
>? "nulo"; | |
let name = person | |
>= (person => person##name) | |
>? "nulo"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment