There are a number of ways to handle this, below shows a couple ways (using a lambda with patterns or type annotations as needed; explicit type annotation of expected function type) :

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

type MyType() =
    member this.Foo(x:int) = printfn "int"
    member this.Foo(s:string) = printfn "string"    
    member this.Foo(x,y) = printfn "twoarg"

let mt = new MyType()
let f1 = fun (x:int) -> mt.Foo(x)
let f2 = fun (s:string) -> mt.Foo(s)
let f3 = fun (x,y) -> mt.Foo(x,y)
let g1 : int -> unit = mt.Foo
let g2 : string -> unit = mt.Foo
let g3 : _*_ -> unit = mt.Foo

By on 2/22/2010 3:58 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