Closed tatumizer closed 9 years ago
Actually, ?? does not cover all the cases. If I want a?.b to be null if a is null, what value of x do you use in (a??x).b to get that result. Besides, this is all sugar - if it isn't concise, there's no point.
Sorry, my bad, I close the issue
Speaking purely theoretically (a??b) is enough in dart (not in other languages!) - we discussed in half-jokingly in the mailing list last year. class Antinull { noSuchMethod() => null; } var A=new Antinull(); Now (x??A).foo is null if x is null :-)
I think instead of several ad-hoc cases (which don't cover all wishes anyway), we can use just a single one: (a??b) Make ?? low precedence operator. My claim is that all proposed constructs can be expressed much cleaner via (a??b) E.g. (x??y).foo=1; (x??y)[42]=5 (x??y)=42 // for this, you can allow it to be lvalue, but syntactically it's the same) z=(x??y)+42;
Note that we can use ?? like this even according to current proposal anyway. Which, together with other methods, leads to the same thing being expressible in different ways. (In another thread, Gilad said he wants to avoid such thing)