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
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
On 11/26/05, David C. [email protected] wrote:
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.
David C. [email protected] writes:
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].
Christian N. wrote:
David
That doesn’t really look much clearer to me…
Cheers,
Daniel
Daniel S. [email protected] writes:
That doesn’t really look much clearer to me…
But it doesn’t hurt duck-typing.
On Nov 26, 2005, at 2:52 PM, Daniel S. wrote:
That doesn’t really look much clearer to me…
Array( foo )
Same effect.
James Edward G. II
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>
Array( foo )
Array[ foo ]
T.
Trans wrote:
Array( foo )
Array[ foo ]
Not quite the same:
foo = [1, 2, 3]
Array(foo) => [1, 2, 3]
Array[foo] => [[1, 2, 3]]
Markus
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs