Question: generic type constraint for method

(Fredy Ferrari) #1

I have a question: does oxygene support generic type constraints on a the method level or only on the class level? And if yes, what’s the syntax and also does this work for global functions/procedures?

ex. something of the form:

function MyFunc([autoclosure] code: Expression<Func<T>>):Boolean where T is struct;

(Patrick Lanz) #2

Hello Fredy,
“T” must be defined after the method name;
there is a “;” missing;
and “struct” is a C# thing.

Your definition should look like this:
function MyFunc<T>([autoclosure] code: Expression<Func<T>>):Boolean; where T is record;

I just have errors about “autoclosure” and “Expression” that are not defined.

(Fredy Ferrari) #3

Ah, of course, it’s too early this morning :slight_smile:

(Fredy Ferrari) #4

Sorry, Patrick, I forgot to tell you: you need to include System.Linq.* in the uses.