Feature suggestion
I find it frustrating that both the left and right sides of a String.concat/+ operator cannot join, for example, string and i32.
In JavaScript, it
- Checks to see if the right side of the binary expression is a
string
- If not, it then checks if the right side has a
.toString(): string method
- If so, it calls it and concatenates
left + right.toString()
Would be quite simple to implement. For example, this would probably work:
export class String {
...
@operator("+")
_concat<T>(left: string, right: T): string {
if (!isDefined(right.toString())) ERROR(...);
return this.concat(left, right.toString());
}
}