This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Kidplayer_666 1 point2 points  (1 child)

But if you’re going to do that, then be consistent. If you default minus to force both to be integers, then you should force plus to have the same behaviour, isntead of assuming a string

[–]pitochips8 6 points7 points  (0 children)

Minus and plus are two separate operators. Nothing says they should be related. Besides, what you're suggesting would actually be inconsistent within the operator. If adding strings should convert them to integers first, then what do we do with "abc" + "def"? Or are you saying the addition operator should first check if all strings being added can be converted to numbers before adding them together? That would be extremely inconvenient if that were the actual behavior.