If I do the following:
def my_method(a)
puts a.inspect
end
m = method(:my_method)
p = Proc.new {|a| puts a.inspect}
begin
arr_of_arrs = [[1]]
arr_of_arrs.each(&m)
arr_of_arrs.each(&p)
m.call(arr_of_arrs.first)
p.call(arr_of_arrs.first)
end
I find that I get different results under JRuby --1.9 and YARV Ruby
1.9.3
YARV Ruby 1.9.3 is all consistent:
[1]
[1]
[1]
[1]
$ ruby --version
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
JRuby --1.9 has different behavior for a method object:
$ jruby --1.9 -S irb
1
[1]
[1]
[1]
$ jruby --1.9 --version
jruby 1.6.7.2 (ruby-1.9.2-p312) (2012-05-01 26e08ba) (Java HotSpot™
64-Bit Server VM 1.7.0_04) [darwin-x86_64-java]
As far as I know, it should output [1] instead of 1 in the first line.
Is this a bug, or have I misunderstood something?
Thanks,
Andrew