With all that is happening in the world, someone decides to spend time to make a meme about NATO being a bad guy?
- 0 Posts
- 5 Comments
The interpreter knows that this is not something anyone will ever do on purpose, so it should not silently handle it.
You basically defied the whole NaN thing. I may even agree that it should always throw an error instead, but… Found a good explanation by someone:
NaN is the number which results from math operations which make no sense
And the above example fits that.
"hello" - 1
makes no sense at all.Yeah but actually there can be many interpretations of what someone would mean by that. Increase the bytecode of the last symbol, or search for “1” and wipe it from string. The important thing is that it’s not obvious what a person who wrote that wants really, without additional input.
Anyway, your original suggestion was about discrepancy between + and - functionality. I only pointed out that it’s natural when dealing with various data types.
Maybe it is one of the reasons why some languages use . instead of + for strings.
If you try what I wrote it will throw a NaN. I was asking about the first part of the proposal.
- should also do some string action
Like what kind of string action?
“Hello” + " world" is what everyone can understand. Switch with “-” and it becomes pointless.
And what happens if we don’t stop it soon? They will attack… Russia or something?