[Lazarus] How to pass function method to TList.Sort?

Anthony Walter sysrpl at gmail.com
Wed Dec 9 22:31:14 CET 2015


// Drop the TMyClass.

function Compare( Item1, Item2 : Pointer ) : Longint;
begin
   case fIndex of
      0:  Result := some compare of Item1, Item2;// These compares are
implemented in an object from another unit
      1:  Result := another compare of Item1, Item2
   end;
end;

Sort takes a function, not a method. There is a difference. A function
pointer is, well one pointer. A method pointer (function/procedure of
object) is tow pointers 1st pointer) for the function 2nd pointer) for the
object instance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20151209/d834aab5/attachment-0003.html>


More information about the Lazarus mailing list