From: Martin DeMello Date: 2007-05-12T06:15:14+09:00 Subject: Re: to_a On 5/11/07, Ari Brown wrote: > Howdy, jewel hunters > > I've been working on the Credit Card problem, and am using the > command .to_a to put my numbers into an array. > > However, I get a warning everytime I do so: > #122_CreditCards.rb:45: warning: default `to_a' will be obsolete > > What should I do instead of to_a? Ruby currently implements Object#to_a, which just returns [self]: obj.to_a -> anArray ------------------------------------------------------------------------ Returns an array representation of obj. For objects of class Object and others that don't explicitly override the method, the return value is an array containing self. However, this latter behavior will soon be obsolete. So you get the deprecation warning when you call to_a on an object of a class that doesn't provide it, so that the implentation defaults to Object#to_a. Use [obj] instead: >> a = 1 => 1 >> a.to_a (irb):2: warning: default `to_a' will be obsolete => [1] >> [a] => [1] martin