warning: default `to_a' will be obsolete

D

David Corbin

I'm getting this warning, which I think is new in 1.8.3.

warning: default `to_a' will be obsolete

However, I can't find what the expected alternative is. Any pointers?

David
 
J

JB Eriksson

------=_Part_33332_24258847.1133029508573
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I'm getting this warning, which I think is new in 1.8.3.

warning: default `to_a' will be obsolete

However, I can't find what the expected alternative is. Any pointers?

David
Object#to_a from ri:

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 it's this "return array containing self" that's going obsolete.

------=_Part_33332_24258847.1133029508573--
 
J

James Edward Gray II

Christian said:
David Corbin said:
I'm getting this warning, which I think is new in 1.8.3.

warning: default `to_a' will be obsolete

However, I can't find what the expected alternative is. Any
pointers? Use [*foo].
David

That doesn't really look much clearer to me...

Array( foo )

Same effect.

James Edward Gray II
 
Y

Yuri Kozlov

and in the 1.9.0 it is already happens
irb(main):001:0> x = 1
=> 1
irb(main):002:0> x.to_a
NoMethodError: undefined method `to_a' for 1:Fixnum
from (irb):2
irb(main):003:0>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top