Skip to content

Instantly share code, notes, and snippets.

@isaacabraham
Created October 17, 2020 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacabraham/a9299f08858b50ef85b7b8a5ca39e632 to your computer and use it in GitHub Desktop.
Save isaacabraham/a9299f08858b50ef85b7b8a5ca39e632 to your computer and use it in GitHub Desktop.
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