On Thursday, 28 June 2018 at 19:22:38 UTC, Jonathan M Davis wrote:
On Thursday, June 28, 2018 18:10:07 kdevel via Digitalmars-d-learn wrote:
On Tuesday, 26 June 2018 at 21:54:49 UTC, Jonathan M Davis wrote: > [H]onestly, I don't understand why folks keep trying to put > nullable types in Nullable in non-generic code.

How do you signify that a struct member of class type is optional?

Structs aren't nullable, so wrapping them in a Nullable makes perfect sense. Whether they happen to be on the stack or members of another type is irrelevant to that. It's wrapping types like pointers and class references in a Nullable that's an odd thing to do - the types where someone might ask why the extra bool is necessary in the Nullable. Wrapping them in a Nullable makes sense in generic code, because the code isn't written specifically for them, but something like Nullable!MyClass in non-generic code is pointless IMHO, because a class reference is already nullable.

- Jonathan M Davis

Reading inpput from a csv file, and the value could either be blank, na, or numeric. Nullable!MyClass could be used to represent 3 states in your programming logic. I'm not saying this is the best way to represent ternary states, but it's not unreasonable.

Jordan Wilson

Reply via email to