Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Array#first should preserve metaclass information.

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@5919 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
commit 0cd807395fff8263c685b8064abf227e66ff0250 1 parent 2720649
@lopex lopex authored
View
2  src/org/jruby/RubyArray.java
@@ -1150,7 +1150,7 @@ public IRubyObject first(IRubyObject[] args) {
throw getRuntime().newArgumentError("negative array size (or size too big)");
}
- return makeShared(begin, (int) n, getRuntime().getArray());
+ return makeShared(begin, (int) n, getMetaClass());
}
/** rb_ary_last
View
2  test/test_array_subclass_behavior.rb
@@ -26,7 +26,7 @@ def test_array_instance_methods_on_subclass
assert_equal(MyArray, (@arr*2).class)
assert_equal(MyArray, @arr.replace([1,2,3]).class)
assert_equal(Array, @arr.last(2).class)
- assert_equal(Array, @arr.first(2).class)
+ assert_equal(MyArray, @arr.first(2).class)
assert_equal(Array, @arr.collect.class)
assert_equal(Array, @arr.collect{true}.class)
assert_equal(Array, @arr.zip([1,2,3]).class)
Please sign in to comment.
Something went wrong with that request. Please try again.