From: Joel VanderWerf Date: 2004-01-25T03:42:53+09:00 Subject: Re: Why is to_a going to be obsolete? daz wrote: > "Joel VanderWerf" wrote: > > >>Don't get too fond of it ;) >> >>irb(main):016:0> [~] irb >>irb(main):001:0> h = {1=>2, :three=>"four"} >>=> {1=>2, :three=>"four"} >>irb(main):002:0> [*h] >>=> [[1, 2], [:three, "four"]] >>irb(main):003:0> class << h >>irb(main):004:1> undef :to_a >>irb(main):005:1> end >>=> nil >>irb(main):006:0> h.to_a >>NoMethodError: undefined method `to_a' for {1=>2, :three=>"four"}:Hash >> from (irb):6 >>irb(main):007:0> [*h] >>NoMethodError: undefined method `to_a' for {1=>2, :three=>"four"}:Hash >> from (irb):7 >> > > > I don't think the future is so gloomy :) > Hash#to_a access is blocked by your code as well as Object#to_a. Quite right. The example shouldn't have been a hash, since Hash#to_a isn't (AFAIK) going away any time soon. A better example: irb(main):001:0> [*Class] => [Class] irb(main):002:0> class Object; undef :to_a; end => nil irb(main):003:0> [*Class] NoMethodError: undefined method `to_a' for Class:Class from (irb):3 IMHO, the future is not made gloomy by this change :-)