On Fri, Dec 5, 2014 at 8:40 PM, Lzaro Armando <lazaro / hcg.sld.cu> wrote:
> Create new arrays after modify the class
>
> irb(main):138:0> class Array
> irb(main):139:1>
> irb(main):140:1*       def second
> irb(main):141:2>          self.at(1)
> irb(main):142:2>       end
> irb(main):143:1>
> irb(main):144:1*     end
> => :second
> irb(main):145:0> %w[1 2 3].second
> => "2"
>
> already created Arrays should have not your custom methods


xi ~ % ruby -e 'a = [1,2,3]; class Array; def second; self[1]; end;
end; p a.second'
2


-- 
Michael Fellinger