Monday, June 20, 2011

Studying F# : Combination of Generics and Discriminated Union

We can use generics in Discriminated Union's of clause.
type Component<'a> =
    | Composite of list<Component<'a>>
    | Leaf of 'a
let compositeSample = Composite([ Leaf(2); Composite([ Leaf(1); Leaf(3) ]) ])

No comments:

Post a Comment