Proposing std.typecons : Optional (with PR)

Jacob Carlborg doob at me.com
Thu Jun 13 09:54:00 UTC 2019


On 2019-06-12 17:58, FeepingCreature wrote:
> 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;`

As I mentioned in the PR, I expect a "orElse" function to be available.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list