Pages

Thursday, December 1, 2011

Type infer in LINQ


If you really want to use LINQ in F#, sometimes you have to specify the type:

counts is a Dictionary
counts
        .OrderByDescending(fun x -> x.Value)
        .Take(8)
        .Select(fun x -> x.Key)   //change this line to the line below will make you compile
        .ToList()


.Select(fun (x:KeyValuePair<_,_>) -> x.Key).  


No comments: