It works as I expect, but I understand why that can be unexpected. Check this out:

1
2
3
4
5
6
7
8
9
10
11
 

let tryit (x: obj) (y: obj) = 
    match x,y with 
    | :? int , int -> printfn "%A" int
    | :? string, string -> ()
    | _ -> ()

tryit 1 42

The second "int" is just an identifier that gets bound to the second value in the tuple (the int object 42 in the case above). Note also that ":? (int * int)" will not work, since there is no relationship between the types Tuple<obj,obj> and Tuple<int,int>. So your first way is 'correct' to do this kind of thing.

By on 6/1/2009 9:28 AM ()

I' did not think about int and string as identifier :).

Now i understand the code.

Thank you

By on 6/1/2009 10:09 AM ()

Oh, and if using Visual Studio, hover over each 'int' for informative tooltips that suggest what's happening.

By on 6/1/2009 9:31 AM ()
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