svg% ruby -e ‘def nil.to_ary() [12] end; p +nil’
[12]
svg%so why doesn’t this give the TypeError then?
Because, like I’ve said, Array#+ call #to_ary and because I’ve defined
^^^^^^^^^^^^^^^^^^^^
Ah, that was the bit I missed. Hmm, it’s only Array that defines
to_ary out of the box… Ah, [RubyTalk:72563] explains why there is
a to_a and a to_ary. This is much clearer now.
The only remaining aspect about this is why the traceback kept
flagging up the error as being in each rather than in the compact!
statement. … Ah, that’s because caller() means caller(1), not
caller(0). I think I see what is happening here.
nil#to_ary it just work
Guy Decoux
Thanks for your patience.
Hugh
···
On Fri, 12 Sep 2003, ts wrote: