3 ms·
> You need to indicate no-data-here in some fashion. Well languages that have non-nullable types still allow you to do that - you just have to be explicit abou
by littlecranky67 7y ago
> You need to indicate no-data-here in some fashion.
Well languages that have non-nullable types still allow you to do that - you just have to be explicit about it. In TypeScript (using --strict mode which disables nullables), youd need to define the type as union type and make use of the "null" type: `let a: string | null`. So you tell the compiler that either "null" is a valid value for a or a string. The compiler will assist you and catch possible bugs (such as dereferencing a without checking it against null first)