I am using Delphi XE4. I am trying to define some helper function for TBytes:
TBytesHelper = record helper for TBytes public function GetLength: integer; end; function TBytesHelper.GetLength: integer; begin Result := System.Length(Self); end;
When I try to use a new helper function:
var B: TBytes; i: integer; begin B := TBytes.Create(1,2,3); i := B.GetLength; if i <> Length(B) then raise Exception.Create('Incorrect result'); end;
I except for the result for i is 3 , but it is not. I refer to the definition of TStringHelper in SysUtils.pas, which has a similar construct.
Is there something I missed?
source share