Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

warning: default `to_a' will be obsolete

547 views
Skip to first unread message

David Corbin

unread,
Nov 26, 2005, 1:10:24 PM11/26/05
to
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


JB Eriksson

unread,
Nov 26, 2005, 1:25:15 PM11/26/05
to
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.

Christian Neukirchen

unread,
Nov 26, 2005, 1:31:02 PM11/26/05
to
David Corbin <dco...@machturtle.com> writes:

Use [*foo].

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


Daniel Schierbeck

unread,
Nov 26, 2005, 3:48:58 PM11/26/05
to
Christian Neukirchen wrote:
> David Corbin <dco...@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

Christian Neukirchen

unread,
Nov 26, 2005, 4:08:10 PM11/26/05
to
Daniel Schierbeck <daniel.s...@gmail.com> writes:

> Christian Neukirchen wrote:
>> David Corbin <dco...@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

James Edward Gray II

unread,
Nov 26, 2005, 4:08:19 PM11/26/05
to

Array( foo )

Same effect.

James Edward Gray II

Trans

unread,
Nov 26, 2005, 5:27:05 PM11/26/05
to
> Array( foo )

Array[ foo ]

T.

Yuri Kozlov

unread,
Nov 27, 2005, 2:12:10 AM11/27/05
to
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>

Markus Koenig

unread,
Nov 27, 2005, 7:38:57 AM11/27/05
to
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

0 new messages