June 13, 2019 Re: Proposing std.typecons : Optional (with PR) | ||||
---|---|---|---|---|
| ||||
Posted in reply to FeepingCreature | 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 |
Copyright © 1999-2021 by the D Language Foundation