Vala lacks a null-safe member access operator
There are a lot of cases where there's a need to access a certain member of some other member, but to do that, one must first check all previous members if they're not null. Here's an example:
var a = obj.a;
if (a == null) {
return;
}
var b = a.b;
if (b == null) {
return;
}
var c = b.c;
if (c == null) {
return;
}
C# 6.0 introduced a new syntax called Null-Conditional Operator
which allows to replace above with:
var c = obj.a?.b?.c;
if (c == null) {
return;
}
Given how often this kind of checking is done, I think it could be a useful addition to Vala. Of course, Vala can use it's own syntax, altough I think C#'s syntax fits Vala too.
Patch 319973, "Patch that provides this capabilities":
Null_safe_member_access.patch
Edited by Rico Tzschichholz