Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6
-
Fix Version/s: JRuby 1.6.1
-
Component/s: Ruby 1.9.2
-
Labels:None
-
Environment:jruby-1.6.0 under OSX 10.6 and ruby-1.9.2p136
-
Number of attachments :
Description
It seems that the behaviour of JRuby's splat operator is to call #to_a on an object to splat it out
$ ruby -v
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0]
$ ruby -e 'class A; def to_a; nil end end; p *A.new'
#<A:0x0000010086dd40>
$ jruby --1.9 -e 'class A; def to_a; nil end end; p *A.new'
TypeError: `to_a' did not return Array
(root) at -e:1
I'm honestly not sure if this is considered a bug in JRuby or MRI, but I'd like to see the behaviour consistent across implementations. It seems related to JRUBY-4584, if that helps.
Sorry, I guess I didn't really complete my initial sentence there. I should have added:
"This causes a problem with objects that return 'nil' for #to_a. Ruby 1.9.2 seems to be fine with these objects (isn't calling #to_a?), but JRuby throws an exception."