Nullable types: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Nullable types
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Nullable types are types which can have no value (can be unassigned). One such type in Pascal is [[Pointer]] type which can have [[Nil|nil]] value which means that it isn't assigned to any specific address. Same behavior can be implemented using [[Generics|generic types]] and advanced records with [[Operator overloading|operator overloading]]. | |
| 2 | + | ||
| 3 | + | The Nullable unit is part of FPC since 3.2.2 and its code can be seen in the GitLab repository: [nullable.pp](https://gitlab.com/freepascal.org/fpc/source/-/blob/main/packages/rtl-objpas/src/inc/nullable.pp). | |
| 4 | + | ||
| 5 | + | Then you can define nullable types like: | |
| 6 | + | ||
| 7 | + | ``` pascal | |
| 8 | + | NullableChar = TNullable<Char>; | |
| 9 | + | NullableInteger = TNullable<Integer>; | |
| 10 | + | NullableString = TNullable<string>; | |
| 11 | + | ``` | |
| 12 | + | ||
| 13 | + | ## See also | |
| 14 | + | ||
| 15 | + | - [[How to use nullable types]] | |
| 16 | + | ||
| 17 | + | The standard nullable type in Object Pascal is Variant. | |
| 18 | + | ||
| 19 | + | - [[Variant]] | |
| 20 | + | ||
| 21 | + | ## External links | |
| 22 | + | ||
| 23 | + | - [FPC GitLab Repository nullable.pp](https://gitlab.com/freepascal.org/fpc/source/-/blob/main/packages/rtl-objpas/src/inc/nullable.pp) | |
| 24 | + | ||
| 25 | + | - [Nullables in Free Pascal and Delphi](https://www.arbinada.com/en/node/1439) | |
| 26 | + | ||
| 27 | + | --- | |
| 28 | + | *From the Free Pascal wiki, page "Nullable types", as it stood on 2022-08-06 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
