Type test on class member
Looks like an additional dispatch is necessary:
let f (v:obj) =
    match v with
    | :? T as t ->
        match t.Base with
        | :? A as a -> a.One
        | :? B as b -> b.Two
        | _ -> "Generic"
    | _ -> "Generic"
By on 4/30/2014 6:27 AM ()
Yes, I can't really see a more concise way to do it.
By on 5/1/2014 6:39 AM ()
Duplication of generic branch prone to errors once you need to change generic response. I thought of inner match already, but it doesn't look as concise as I used in F# :)
By on 5/4/2014 12:54 AM ()
IntelliFactory Offices Copyright (c) 2024 IntelliFactory. All rights reserved.
| | | Trainings | | |
Built with