Warning: default `to_a' will be obsolete

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.

···

On 11/26/05, David Corbin <dcorbin@machturtle.com> 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

David Corbin <dcorbin@machturtle.com> 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].

···

David

--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org

Christian Neukirchen wrote:

David Corbin <dcorbin@machturtle.com> 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].

David

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

Cheers,
Daniel

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>

Daniel Schierbeck <daniel.schierbeck@gmail.com> writes:

Christian Neukirchen wrote:

David Corbin <dcorbin@machturtle.com> 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].

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

But it doesn't hurt duck-typing.

···

Daniel

--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org

Array( foo )

Same effect.

James Edward Gray II

···

On Nov 26, 2005, at 2:52 PM, Daniel Schierbeck wrote:

Christian Neukirchen wrote:

David Corbin <dcorbin@machturtle.com> 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].

David

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

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