Skip to content

Instantly share code, notes, and snippets.

@kommen
Created December 1, 2011 11:15
Show Gist options
  • Save kommen/1415940 to your computer and use it in GitHub Desktop.
Save kommen/1415940 to your computer and use it in GitHub Desktop.
Ruby Array inheritance change
class MyArray < ::Array
end
a = MyArray.new
puts a.class
puts a.reverse.class
$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
$ ruby array_test.rb
MyArray
Array
$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]
$ ruby array_test.rb
MyArray
MyArray
$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin11.2.0]
$ ruby array_test.rb
MyArray
MyArray
$ ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-darwin11.2.0]
$ ruby array_test.rb
MyArray
MyArray
$ ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
$ ruby array_test.rb
MyArray
MyArray
@kommen
Copy link
Author

kommen commented Dec 1, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment