4 ms·
I see. Coming from swift the ?. syntax feels weird to me because it implies there is some property accessed or method called when there is not. Ambiguity with
by yoz-y 7y ago
I see. Coming from swift the ?. syntax feels weird to me because it implies there is some property accessed or method called when there is not.
Ambiguity with ternary operator is unfortunate but this one is lifted (in Swift) by harder rules on whitespace. A postfix operator must not have space between the variable and the ?: operator must have space around.
- munificent 7y ago> Coming from swift the ?. syntax feels weird to me because it implies there is some property accessed or method called when there is not. There is. "[]" is a method in Dart. In Dart, almost all operators are syntactic sugar for corresponding method calls on the left-hand operand. In Dart, lists and maps are built into the core library, but the "[]" syntax is not special to those types. Any user-defined class is free to implement the subscript operator too. In practice, this is useful because it means user-defined classes can implement the List and Map interfaces. This gives user collections the same ease of use as built-in ones.