[fpc-pascal] Default record const values
Benjamin Rosseaux
benjamin at rosseaux.com
Wed Nov 28 20:27:22 CET 2018
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 <ryan at 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 at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20181128/346fd520/attachment.html>
More information about the fpc-pascal
mailing list