Last active
December 17, 2021 17:05
-
-
Save lucasmoreiradev/c92946827e0b1cd6e084ce81ce2fdcb5 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
(* OCaml *) | |
type person = { | |
name: string; | |
age: int; | |
} | |
let happy_birthday user = match user with | |
| Some person -> String.concat " " ["Happy Birthday"; person.name] | |
| None -> "Is not logged" | |
let lucas = { | |
name = "Lucas"; | |
age = 28; | |
} | |
let option = Some lucas | |
let _ = happy_birthday option |
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
// ReasonML | |
type person = { | |
name: string, | |
age: int, | |
}; | |
let happy_birthday = user => { | |
switch (user) { | |
| Some(person) => "Happy birthday " ++ person.name | |
| None => "Please login first" | |
}; | |
}; | |
let user = Some({name: "Lucas", age: 28}); | |
print_endline(happy_birthday(user)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment