Created
December 8, 2017 04:51
-
-
Save lagenorhynque/5d42b5cbb32f6ea034a041f03984c0df to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| > maybe "undefined" (show . (^ 2)) (Just 42) | |
| "1764" | |
| > maybe "undefined" (show . (^ 2)) Nothing | |
| "undefined" |
This file contains hidden or 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
| user=> (if-let [x 42] (str (* x x)) "undefined") | |
| "1764" | |
| user=> (if-let [x nil] (str (* x x)) "undefined") | |
| "undefined" |
This file contains hidden or 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
| scala> (Some(42): Option[Int]).fold("undefined")(n => (n * n).toString) | |
| res0: String = 1764 | |
| scala> (None: Option[Int]).fold("undefined")(n => (n * n).toString) | |
| res1: String = undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment