GNOME Bugzilla – Bug 725356
request: add safe navigation operator
Last modified: 2018-02-24 11:39:47 UTC
It seems like it would be useful to add a safe navigation operator so accessing children of children on an object can be done conveniently without having to check for nullity until the end. Eg, this would be safe regardless of the nullity of any of the members on the right side: var foo = parent?.child1?.child2; if (foo != null) { // continue } This saves a lot of noisy code in cases where you only care if you can access the endpoint member. C# is adding this as "?.". More explanation here: http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx
There was a discussion already about this on the vala mailing list, can't find the relevant bits though.
*** This bug has been marked as a duplicate of bug 761267 ***