Is there anything other than nullable to work with optional types?

ali ak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Dec 25 14:19:11 PST 2016


On Sunday, 25 December 2016 at 20:01:21 UTC, Stefan Koch wrote:
> Well there is one easy way to do this.
> pass a pointer to the data.
> Another easy one is the definition of one invalid set of values 
> and using that is initial value and for convenience overload 
> opCast(T:bool) to check against that instance.

Well sure, certainly solutions. Could also use exception. But I'm 
looking for the enhanced API clarity, reduced pointer related 
errors, and added type safety that optionals usually provide, and 
it seems the closest thing in D was Nullable.


More information about the Digitalmars-d-learn mailing list