Since I tend to forget this: [WayBack] Spring4D How to correctly assign NULL to a Nullable type? this is correct? fDateTime = Null; or this? fDateTime := nil; – Jacek Laskowski – Google+
The preferred way is fDateTime := nil
.
This is possible because of [WayBack] Delphi sorcery: How to create an operator overload that only accepts nil using a reference type (in this case interface
) so no non-nil pointers can be passed:
type Nullable<T> = record strict private type Null = interface end; public class operator Implicit(const value: Null): Nullable<T>; end;
–jeroen