Forum: JRuby Handling of arguments by method object

01bbb59a1c3ef9960f25a97afe7e920f?d=identicon&s=25 Andrew Grimm (Guest)
on 2012-07-05 09:39
(Received via mailing list)
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
<snip code>
1
[1]
[1]
[1]

$ jruby --1.9 --version
jruby 1.6.7.2 (ruby-1.9.2-p312) (2012-05-01 26e08ba) (Java HotSpot(TM)
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
F1d37642fdaa1662ff46e4c65731e9ab?d=identicon&s=25 Charles Nutter (headius)
on 2012-07-08 01:20
(Received via mailing list)
It is a bug...please file it :)

- Charlie
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.