From: Gennady Date: 2004-01-24T03:15:34+09:00 Subject: Re: Why is to_a going to be obsolete? Joel VanderWerf wrote: > Gennady wrote: > >> I was also surprised to learn that Object#to_a is going to be >> obsolete. However, I immediately found a replacement for it that I >> like even more: >> >> instead of doing >> o.to_a >> >> I do now >> [ *o ] >> >> And this is not reported as obsolete in Ruby 1.8.1 yet ;-) > > > 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 > > It shows only that currently '*' for hashes implemented via to_a, no more. In any rate, I am with OP on this -- it would be nice to hear from Matz about Object#to_a becoming obsolete and relevance of "[ *o ]" for the future. Gennady.