Skip to content

Instantly share code, notes, and snippets.

@davidgrenier
Created December 2, 2011 16:14
Show Gist options
  • Save davidgrenier/1423793 to your computer and use it in GitHub Desktop.
Save davidgrenier/1423793 to your computer and use it in GitHub Desktop.
Pattern > If example
type Status = Active | Standby | Inactive
let status = Active
let isOnline = true
if not isOnline then
printfn "Status is offline or inactive"
else
match status with
| Active -> "Status is active"
| Standby -> "In Standby"
| Inactive -> "Status is offline or inactive"
|> printfn "%s"
// vs
printfn <|
match isOnline, status with
| false, _ | _, Inactive -> "Status is offline or inactive"
| _, Active -> "Status is active"
| _, Standby -> "In Standby"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment