How can Delphi records be initialized automatically?
问题 To initialize Delphi records I've always added a method (class or object) that would initialize to known good defaults. Delphi also allows for defining record "constructors" with parameters, but you cannot define your own parameter-less "constructor". TSomeRecord = record Value1: double; Value2: double; procedure Init; end; procedure TSomeRecord.Init; begin Value1 := MaxDouble; Value2 := Pi; end; Given the record above there is no warning that a record has not been initialized. Developers may