From: daz Date: 2004-01-25T01:19:56+09:00 Subject: Re: Why is to_a going to be obsolete? "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. #---------- p Object.instance_methods(true).grep(/^to_/) module Kernel undef :to_a end p Object.instance_methods(true).grep(/^to_/) h = {1=>2, :three=>"four"} p [*h] #-> ["to_a", "to_s"] #-> ["to_s"] #-> [[1, 2], [:three, "four"]] #---------- In a later post, "Dan Janowski" wrote: > > My apology, I read a few more messages: to_a will still be the > sanctioned way for an object to emit itself as an array, but Object > will not include such a method. Correct? > > Dan > That's how I see it. daz