On 2013-12-10 17:28:26 +0000, Andrei Alexandrescu said:
I talked to a programmer who knows Scala (among others) and he
mentioned the usefulness of the Option type - a zero or one element
collection (range in D terminology). Here's an article discussing it:
http://danielwestheide.com/blog/2012/12/19/the-neophytes-guide-to-scala-part-5-the-option-type.html
We have only(x) (http://dlang.org/phobos/std_range.html#.only) to be a
collection of exactly one value, but not a type for "a value of type T
or nothing at all". Should we follow Scala's example and add it?
Andrei
Yes! Option is super useful. Use it all the time in Scala and Java (via
Guava library).
I suppose it will be defined as a range, so map will work on it?
One of the useful things about options are the ability to chain them
via flatMap, will this usecase be handled?