Just curious why I can't do this:
let myFn (data : obj) =
match data with
| :? (string * string) as (s1, s2) -> sprintf "(%s, %s)" s1 s2 |> Some
| :? (string * string * int) as (s1, s2, i) -> sprintf "(%s, %s, %d)" s1 s2 i |> Some
| _ -> None
How come?
obj
and type matching. F# should be used in a type-safe way, and use ofobj
and downcasting detracts from that. – Angelicangelica