Created
February 29, 2012 14:56
-
-
Save tkellogg/1941345 to your computer and use it in GitHub Desktop.
Example of option types in F#
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 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