[Lazarus] How to implement an iif with generic?

silvioprog silvioprog at gmail.com
Thu Jan 26 03:13:57 CET 2012


Hello,

I'm tried all options in
http://wiki.freepascal.org/Generics_proposals. But, without success.
:(

In the last test:

function Max<T>(A, B: T): T;
begin
  if A < B then
    Result := B
  else
    Result := A;
end;

The error is: unit1.pas(30,13) Fatal: Syntax error, ":" expected but "<" found.

What is the syntax for implementing a generic function? I'm trying to
implement an faster iif function.

Thanks,

-- 
Silvio Clécio
====================================
Site - <silvioprog.com.br>
LazSolutions - <code.google.com/p/lazsolutions>
====================================




More information about the Lazarus mailing list