[Lazarus] Thanks to FPC team: Record helper for primitive types!
silvioprog
silvioprog at gmail.com
Sat Nov 29 16:54:56 CET 2014
Hello,
Today I compiled my FPC from trunk and saw the following possibility:
{ TIntegerHelper }
TIntegerHelper = record helper for Integer
function ToString: string;
end;
...
{ TIntegerHelper }
function TIntegerHelper.ToString: string;
begin
Result := IntToStr(Self);
end;
...
var
I: Integer = 123;
begin
WriteLn(I.ToString); // Prints 123
end.
Or:
{ TStringHelper }
TStringHelper = record helper for String
function ToUpperCase: string;
end;
...
uses
LazUTF8;
{ TStringHelper }
function TStringHelper.ToUpperCase: string;
begin
Result := LazUTF8.UTF8UpperCase(Self);
end;
...
var
S: UTF8String = 'atenção';
begin
WriteLn(S.ToUpperCase); // Prints ATENÇÃO
// or
WriteLn('atenção'.ToUpperCase); // Prints ATENÇÃO
end.
It's evolution, baby! =)
Thanks alot for this great implementation, FPC team! (and special thanks to
Sven!) =D
--
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20141129/d7657a11/attachment-0002.html>
More information about the Lazarus
mailing list