views:

319

answers:

2

Is there a way in Boo to express some constaints on generic types as we can do using the where clause in C#?

In short, how to write?:

class MyClass<T>
    where T:Icomparable<T>
    {...}

Thank you

+2  A: 

Yes. The syntax is the same as declaring base types:

class MyClass[of T(IComparable of T)]

Or, for other constraints:

class MyClass[of T1(class, constructor), T2(struct)]

I think that the current development version of Boo doesn't support generic type parameter constraints that refer to themselves or to other generic type parameters; I might be mistaken though.

Avish