[Lazarus] Method in record type, is possible?

Graeme Geldenhuys graemeg.lists at gmail.com
Wed Mar 16 08:58:41 CET 2011


Op 2011-03-16 04:24, silvioprog het geskryf:
>
> This is possible in Lazarus/FPC?:
>
> type
>    TFoo = record
>      Value: string;
>      function AsBoolean: Boolean;
>    end;
>
> function TFoo.AsBoolean: Boolean;
> begin
>    Result := StrToBoolDef(Value, False);
> end;
>
> In Delphi:
>
> http://edn.embarcadero.com/article/34324

That is the stupidest feature I have seen in Delphi. They simply 
rehashed something that existed since pre-Delphi v1, and then call it 
something "new". What you are looking for is the age old Object structure.

     TFoo = object
       Value: string;
       function AsBoolean: Boolean;
     end;


And yes, FPC supports the Object structure. ;)


Regards,
   - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/





More information about the Lazarus mailing list