Generics in Boo - Is there a C # where clause equivalent

Is there a way in Boo to express some constants in generic types, how can we do using the where clause in C #?

In short, how to write ?:

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

thanks

+3
source share
2 answers

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

class MyClass[of T(IComparable of T)]

Or, for other restrictions:

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

I think that the current version of Boo development does not support the general restrictions of type parameters that refer to themselves or to other type type parameters; Maybe I'm wrong.

+5
source

Source: https://habr.com/ru/post/1716494/


All Articles