Environment Information
$ jruby -v
jruby 9.4.9.0 (3.1.4) 2024-11-04 547c6b150e OpenJDK 64-Bit Server VM 21.0.5+11-Ubuntu-1ubuntu124.04 on 21.0.5+11-Ubuntu-1ubuntu124.04 +jit [x86_64-linux]
$ uname -a
Linux 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
In Ruby 3.3.6, the following two execution results are the same:
$ ruby -e '[[1,2],[3,4],[5,6]].each_with_index.uniq {|x| p x}'
[1, 2]
[3, 4]
[5, 6]
$ ruby -e '[[1,2],[3,4],[5,6]].each_with_index.map {|x| p x}'
[1, 2]
[3, 4]
[5, 6]
In JRuby 9.4.9.0, the following two execution results are different:
$ jruby -e '[[1,2],[3,4],[5,6]].each_with_index.uniq {|x| p x}'
[[1, 2], 0]
[[3, 4], 1]
[[5, 6], 2]
$ jruby -e '[[1,2],[3,4],[5,6]].each_with_index.map {|x| p x}'
[1, 2]
[3, 4]
[5, 6]
I thought the output of uniq in JRuby was correct, but which one is actually correct?
Environment Information
In Ruby 3.3.6, the following two execution results are the same:
In JRuby 9.4.9.0, the following two execution results are different:
I thought the output of uniq in JRuby was correct, but which one is actually correct?