2 ms·
F# also has: let foo : obj = failwith "" match foo with | :? SomeType as blah -> // use blah : SomeType (You're allowed to just use the identifie
by Smaug123 4y ago
F# also has:
let foo : obj = failwith ""
match foo with
| :? SomeType as blah ->
// use blah : SomeType
(You're allowed to just use the identifier `foo` in the match arm.)
- halfmatthalfcat 4y agoAs does Scala: match thing { case a: String => // use a as string case a @ MyCaseClass(b: String, c, d) => // use a as the instance of MyCaseClass or use b as a string }