From: "Brian Schröder" Date: 2005-08-13T01:12:08+09:00 Subject: Re: Array redefinition problem > It's a web script, so I never noticed this warning in a class below the > array redef: > warning: redefining Object#initialize may cause infinite loop > > I had a "begin" in there that was unmatched, and a rescue several > functions later - > which was causing some real strange things. > > Anyway, now that I have put the begin in the same function as the rescue, > I no longer get the error. But I still can't redefine Array - now I get: > > /var/www/ruby/core.rb:22:in `num_rows': undefined local variable or > method `length' for #<#::Array:0xb65e2c78> (NameError) > > The first lines of the program are: > class ::Array > def num_rows > return length <--- LINE 22 > end > end > > a = Array.new > puts a.num_rows > > -- so how do I access ::Array.length? class Array alias :num_rows :length end [1,2,3].num_rows #=> 3 -- http://ruby.brian-schroeder.de/ Stringed instrument chords: http://chordlist.brian-schroeder.de/