I must admit I fully expected the following code not to work at all, but was pleasantly surprised.

I must admit I fully expected the following code not to work at all, but was pleasantly surprised.

Cheers Delphi :)

type
  TRec = record
    v1, v2: UInt64;
    class operator Implicit(const v: array of UInt64): TRec;
  end;
{ TRec }
class operator TRec.Implicit(const v: array of UInt64): TRec;
begin
  result.v1 := v[0];
  result.v2 := v[1];
end;
var
  r: TRec;
begin
  r := [42, 123];
  WriteLn(r.v1);
  WriteLn(r.v2);
end.

Comments