扩展

type
  //record helper extends simple types;
  //NOTE: only one helper is active per
  //type, this hides SysUtils helpers
  TIntHelper = record helper for Integer
    function IsEven: Boolean;
  end;

function TIntHelper.IsEvenBoolean;
begin
  Result := Self mod 2 = 0;
end;

var
  N: Integer;
begin
  N := 42;

  WriteLn('isEven is ', N.IsEven);
  //isEven is True

  WriteLn('isEven is '7.IsEven);
  //isEven is False
end.