3 ms·
There's a language where `{} + {}` does something useful? Or is the complaint that it should `TypeError`?
by jkrems 13y ago
There's a language where `{} + {}` does something useful? Or is the complaint that it should `TypeError`?
- pekk 13y agoIf it does anything at all, it certainly shouldn't generate NaN
- tel 13y agoWhy not? If (+) is numeric addition and coercion is free then {} is NaN and so is {} and so is NaN + (anything) and so is (anything) + NaN. Which is not to say that it's a good choice, but instead to say that the badness stems from overloading (+) too much and having free coercion.
- anonymouz 13y agoIt's obviously {}, duh! ;) (In one of the ways of constructing the natural numbers within ZFC set theory in mathematics, one identifies 0 with the empty set {}, 1 with {{}}={0}, 2 with { {}, {{}}} = {0,1}, and so on.)