Proposing std.typecons : Optional (with PR)

FeepingCreature feepingcreature at gmail.com
Wed Jun 12 15:58:23 UTC 2019


On Wednesday, 12 June 2019 at 11:56:57 UTC, aliak wrote:
> These algorithms are already there if it's implemented as a 
> range. There's no need to reimplement them.

For instance, `orElse` is the very clear and understandable 
`5.optional.chain(7.only).front`.

Which, if you are at all interested in readability, you'll `alias 
orElse = (a, b) => a.chain(b.only).front;` anyways. At which 
point you might as well `alias orElse = (a, b) a.present ? 
a.value : b;`


More information about the Digitalmars-d mailing list