Let’s say I have the following discriminated union and value:
type DisUnion =
| One of string
| Two of string
| Three of string * string
let myVal = One("One")
I know I can use pattern matching to determine which case myVal belongs to, like this:
let whatever (x : DisUnion) = match x with
| One(str) -> "It was One"
| Two(str) - > "It was two"
| Three(str, str) -> "It was three"
But I can’t seem to find an operator or method that allows me to determine the case identifier without pattern matching, like:
let isOne (x : DisUnion) = x :? One //I thought this would work, but it doesn't.
How would I do this? Any help is appreciated.
Note that this is equivalent to: