Closed
Description
void f(int? i) {
var s1 = '' + i;
var s2 = '$i';
}
It is currently not allowed to assign a nullable (int
, String
, etc.) to a String
as required by the concatenation +
.
However, interpolation handles it gracefully.
Would it make sense to also handle it in concatenation, after the +
, or even before (if detected as concatenation)?
So the below would be allowed:
void f(String? s) {
var s1 = s + s;
var s2 = '$s$s';
}
I know that interpolation is the preferred way, but as concatenation is there, I guess it would make the language a little smarter.