On Wednesday, 18 June 2014 at 17:56:46 UTC, Mattcoder wrote:
On Wednesday, 18 June 2014 at 15:42:04 UTC, Etienne wrote:
it would be a little more practical to be able to write

writeln(obj.member?.nested?.val);

If one of these: member, nested or val == null, what will happen with writeln()? It will print null or it will be avoided?

The expression needs to have exactly one type, and because all of the components can be non-null, it needs to be the type of the last component, in this case `val`. This means that if the one of the components is null, the entire expression needs to return a value of this type, presumably the `.init` value.

The alternative is to raise an exception (or error), but that would defeat the purpose (almost, as it would be slightly better than segfaulting).

Reply via email to