program Test123;
{$ifdef fpc}
  {$mode delphi}
{$endif}

type
  TTest = record
  public
    a: LongInt;
    b: LongInt;
  end;

  TTestHelper = record helper for TTest
  public
    const Default: TTest = (a: 1; b: 2);
  end;

var
  Test: TTest;
begin
  Test := TTest.Default;
end.

On Sat, Nov 10, 2018 at 10:06 AM Ryan Joseph <r...@thealchemistguild.com>
wrote:

> Should’t this work? This would be a good way to set default record values
> but it doesn’t seem to be supported.
>
>
> type
>         TMyRecord = record
>                 public
>                         a: integer;
>                         b: string;
>                 const
>                         default: TMyRecord = (a: 100; b: 'foo');
>         end;
>
> var
>         r: TMyRecord = TMyRecord.default;
>
>
> Regards,
>         Ryan Joseph
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to