Adding the ?. null verification

Nick Treleaven via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 19 04:31:20 PDT 2014


On 18/06/2014 21:20, "Ola Fosheim Grøstad" 
<ola.fosheim.grostad+dlang at gmail.com>" wrote:
> On Wednesday, 18 June 2014 at 15:42:04 UTC, Etienne wrote:
>>
>> writeln(obj.member?.nested?.val);
>>
>
> Optional chaining in swift is meant to be used more like this:
>
> if let v = ptr?.attr?.getobj?()?.attr? {
>    writeln(v)
> } else {
>    writeln("oops?!")
> }
>
> (I don't think Maybe will look as good.)

Perhaps Maybe could implement opCast!bool, then we could do:

if (auto v = ...)


More information about the Digitalmars-d mailing list