Skip to content

Instantly share code, notes, and snippets.

@tkellogg
Created February 29, 2012 14:56
Show Gist options
  • Save tkellogg/1941345 to your computer and use it in GitHub Desktop.
Save tkellogg/1941345 to your computer and use it in GitHub Desktop.
Example of option types in F#
let find kittens =
match kittens.IndexOf("kittens") with
| -1 -> None
| x -> Some kittens.SubString(x, 7)
match find "a box of kittens" with
| None -> printf "no kittens"
| Some container -> printf "kittens found inside '%s'" container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment