by LoganDark · 1mo ago · 0 comments
Also, 1 + "hello" is "1hello", obviously. Have you never read JavaScript? :)
Exactly. And if that were the case, you couldn't do very much type checking at compile time.
Javascript, or more specifically Typescript, is precisely why I wrote "In most statically typed languages..."
In Typescript, you can write `1 + "hello"` and the type system will infer that the type of that term is 'string'. It doesn't change anything I wrote above.
What trips us up is having existing expectations for what an operator called + should do.
No, it's obviously "ello" have you not heard of C?