On Wednesday, 18 June 2014 at 15:42:04 UTC, Etienne wrote:
I find myself often repeating this boilerplate:
if (obj.member !is null)
{
if (obj.member.nested !is null)
{
if (obj.member.nested.val !is null)
{
writeln(obj.member.nested.val);
}
}
}
I have to admit it's a little frustrating when you see swift's
?. syntax notation, it would be a little more practical to be
able to write
writeln(obj.member?.nested?.val);
Based on
http://appventure.me/2014/06/13/swift-optionals-made-simple/
Any thoughts?
C# is getting the same syntax, and I remember there being some
discussion about it here. It's somewhat useful I suppose, though
I think it's made significantly more useful in C# with 'a ?? b'
(a if a is not null, else b).