Optional<T> equivalent in D?

Brad Anderson eco at gnuk.net
Fri Nov 15 14:41:38 PST 2013


On Friday, 15 November 2013 at 22:39:40 UTC, Jacek Furmankiewicz 
wrote:
> Many other languages are starting to frown on returning null 
> values from methods (due to NullPointerException risks, etc) 
> and wrapping them instead in an Optional<T> like in
>
> Scala:
> http://blog.danielwellman.com/2008/03/using-scalas-op.html
>
> Google Guava for Java: (now rolled into the base JDK for Java 
> 8):
> https://code.google.com/p/guava-libraries/wiki/UsingAndAvoidingNullExplained
>
> Is there a similar approach in D? Or maybe an equivalent is in 
> a commonly used external library?

Sounds like std.typecons.Nullable to me.


More information about the Digitalmars-d-learn mailing list