Incorrect usage:
In the following snippet, the last match will never be used:
let x = 4
match x with
| 1 -> printfn "x is 1"
| _ -> printfn "x is anything that wasn't listed above"
| 4 -> printfn "x is 4"
prints
x is anything that wasn't listed above
Correct usage:
Here, both x = 1
and x = 4
will hit their specific cases, while everything else will fall through to the default case _
:
let x = 4
match x with
| 1 -> printfn "x is 1"
| 4 -> printfn "x is 4"
| _ -> printfn "x is anything that wasn't listed above"
prints
x is 4