Created
October 17, 2020 11:55
-
-
Save isaacabraham/a9299f08858b50ef85b7b8a5ca39e632 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
let maybeAValue = Some "Test" | |
let firstVersion = [ | |
"Hello" | |
"There" | |
match maybeAValue with // <- explicit match on option and yield only on Some x | |
| Some v -> v | |
| None -> () | |
] | |
let secondVersion = [ | |
"Hello" | |
"There" | |
yield! maybeAValue |> Option.toList // makes a list of 0 or 1 items (None -> [], Some x -> [ x ]) which can be natively yielded. | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment