Extended Array loses it's instance variables if processed with #reject
----------------------------------------------------------------------
Key: JRUBY-5718
URL: http://jira.codehaus.org/browse/JRUBY-5718
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.6.1
Reporter: Arturas Slajus
Priority: Critical
Test case:
{noformat}
class A < Array
attr_reader :extra
def initialize(items, extra)
super(items)
@extra = extra
end
def inspect
"A[#{@extra}]#{super}"
end
end
puts "#{RUBY_VERSION} #{RUBY_PLATFORM}"
a = A.new([1,2,3,4], :x)
puts a.reject { |i| i > 2 }.inspect
{noformat}
Output:
{noformat}
arturas@arturaz-fujitsu:~/work/spacegame/server$ rvm use 1.9.2
Using /home/arturas/.rvm/gems/ruby-1.9.2-p180
arturas@arturaz-fujitsu:~/work/spacegame/server$ ruby test.rb
1.9.2 i686-linux
A[x][1, 2]
arturas@arturaz-fujitsu:~/work/spacegame/server$ rvm use jruby-1.6.1
Using /home/arturas/.rvm/gems/jruby-1.6.1
arturas@arturaz-fujitsu:~/work/spacegame/server$ JRUBY_OPTS="" jruby test.rb
1.8.7 java
A[][1, 2]
arturas@arturaz-fujitsu:~/work/spacegame/server$ JRUBY_OPTS="--1.9" jruby
test.rb
1.9.2 java
A[][1, 2]
{noformat}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email