[Pas2js] Testing generics
warleyalex
warleyalex at yahoo.com.br
Wed Oct 23 15:19:51 CEST 2019
class procedure issue in fpc mode.
I would like this code:
---------------------------------------------
type
generic TGen<T> = record
class procedure Proc(item: T); static;
end;
generic class procedure TGen<T>.Proc(item: T);
begin
//console.log(SizeOf(T));
if item > 0 then
WriteLn('Positive')
else if item < 0 then
WriteLn('Negative')
else
WriteLn('Zero');
end;
---------------------------------------------
begin
specialize TGen<LongInt>.Proc(0); // Zero
specialize TGen<Int64>.Proc(123); // Positive
specialize TGen<Extended>.Proc(-11); // negative
end;
The compiler says: Error: class procedure expected, but procedure found
I think when we inform the "generic" keyword behind the class procedure.
--
Sent from: http://pas2js.38893.n8.nabble.com/
More information about the Pas2js
mailing list