3 ms·
Oh really? Suppose x = 123 and x = "123" were "THE SAME THING". What's x + "42"? What's x + "042"? What's x + "a"? What's x + "e2"? What's x + "e2" + 1234
by zestyping 4y ago
Oh really? Suppose x = 123 and x = "123" were "THE SAME THING".
What's x + "42"?
What's x + "042"?
What's x + "a"?
What's x + "e2"?
What's x + "e2" + 12345?
What's x + "1,500"?
What's 1 / x?
- wvenable 4y agoTo be fair, that's more weak vs. strong and not static vs. dynamic. You can have a dynamic typed language where all these are cough runtime errors.
- nyanpasu64 4y agoIf 123 and "123" were the same thing, then 123 + 123 must be equivalent to "123" + "123", and 123 + "123" cannot be made a runtime error. And I do think PHP (the poster child for weak typing, second to Bash) uses a separate . operator for string concatenation (rather than +), and relies on I think -> for object field access.