Delphi does default initialize global variables and member variables of objects. It doesn't default initialize local variables (but it should for consistency).
Inline variable declaration with initialization makes it a bit nicer. You can write:
var myVar := 25;
To initialize myVar and type inference will make it an Integer. You can specify type if needed:
Inline variable declaration with initialization makes it a bit nicer. You can write:
To initialize myVar and type inference will make it an Integer. You can specify type if needed: In their examples they say: But actually n2 is initialized to zero.And in the example freeing of objects, instead of using:
They should always use: That will free the object and set the object pointer to nil. Any subsequent attempt to access obj1 will result in an access violation.