Hi --

On Tue, 11 Mar 2008, MenTaLguY wrote:

> On Tue, 2008-03-11 at 08:40 +0900, David A. Black wrote:
>> irb(main):002:0> obj = Object.new
>> => #<Object:0x3cb748>
>> irb(main):003:0> obj.to_a
>> NoMethodError: undefined method `to_a' for #<Object:0x3cb748>
>> irb(main):004:0> [*obj]
>> => [#<Object:0x3cb748>]
>>
>> Am I right in interpreting this to mean that * works by doing an
>> implicit to_a-ish operation, unless to_a is defined in which case it
>> uses to_a? (I was kind of expect it not to work in the absence of the
>> default to_a, though I'm happy if it does.)
>
> I believe the splat operator is based on Array(), not #to_a directly.

Thanks -- that makes sense.


David

-- 
Upcoming Rails training from David A. Black and Ruby Power and Light:
   ADVANCING WITH RAILS, April 14-17 2008, New York City
   CORE RAILS, June 24-27 2008, London (Skills Matter)
See http://www.rubypal.com for details. Berlin dates coming soon!