<deleted>

By on 8/29/2009 2:45 AM ()

You have to match, but you can encapsulate the matching in a function. E.g

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 

type Foo =
    | I of int
    | S of string
    with
        member this.GetInt() =
            match this with
            | I(x) -> x
            | _ -> failwith "oops"
        member this.GetString() =
            match this with
            | S(s) -> s
            | _ -> failwith "oops"

let myFooInt = I 42
let fooVal = myFooInt.GetInt()
By on 8/29/2009 7:02 AM ()

Thanks Brian. I'll copy your answeer accross to where I re-raised this question in "Howto's and snippets"

By on 8/29/2009 6:27 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper