[Pas2js] Fields default values

warleyalex warleyalex at yahoo.com.br
Sat Jun 30 14:30:16 CEST 2018


It would be handy if Record and class fields could have default values, and
can be type-inferenced.
------------
type
   TMyClass = class
   private
     Field0 : String = 'hello';    // ---> Field1 set to ‘hello‘ by default
(instead of an empty string)
     Field1 := 'hello';             // ----> can be type-inferenced. 
     Field2 : Integer = 123;    // ----> Field2 will be initialized to 123.
     FEnabled: Boolean=True;
     FInterval: Integer=1000;
    published
     property Interval: Integer read FInterval write FInterval default 1000;
   end; 
------------



--
Sent from: http://pas2js.38893.n8.nabble.com/


More information about the Pas2js mailing list