3 ms·
Python does: >>> {"foo": [1, 2, set([True])]} == {"foo": [1, 2, set([False])]} False >>> {"foo": [1, 2, set([True])]} == {"foo": [int('1'), 2, set([bool(1)])
by sametmax 9y ago
Python does:
>>> {"foo": [1, 2, set([True])]} == {"foo": [1, 2, set([False])]}
False
>>> {"foo": [1, 2, set([True])]} == {"foo": [int('1'), 2, set([bool(1)])]}
True
- Sacho 9y agoYou're right, I forgot about those and overstated my case.
- always_good 9y agoI don't blame you. I think the only reason I ever do deep comparison is in unit tests, and every test/assertion library has a `deepEquals` assertion, so it's not something I regularly miss. There are better examples of deficiencies in Javascript's standard library, especially when targeting browsers, but Javascript has made massive strides lately like its native Set and Map datastructures. For example, Set doesn't come with the classic methods `.intersection()` / `.difference()` / `.union()` / etc. but it's just not a defining moment of my overall experience with Javascript. We're long past the days where you had to bring your own `Array#map`, but I don't know if all of these commenters are.
- robhu 9y agoRuby too: irb(main):002:0> {'foo' => [1, 2, [true].to_set]} == {'foo' => [1, 2, [false].to_set]} => false irb(main):003:0> {'foo' => [1, 2, [true].to_set]} == {'foo' => ['1'.to_i, 2, [true].to_set]} => true
- deleted 9y ago[deleted]