From: James Edward Gray II Date: 2005-12-20T00:35:00+09:00 Subject: Re: Spawning On Dec 19, 2005, at 9:25 AM, Logan Capaldo wrote: > > On Dec 19, 2005, at 10:15 AM, James Edward Gray II wrote: > >> On Dec 19, 2005, at 9:02 AM, Logan Capaldo wrote: >> >>> Apparently splat will splat almost anything as long as its to_a >>> method returns an array (a reasonable assumption). I don't know >>> if I really like this. I always kind of thought of splat as >>> syntax (like &), not really as a method (operator). >> >> & works on anything with a to_proc(). See: >> >> http://blogs.pragprog.com/cgi-bin/pragdave.cgi/Tech/Ruby/ToProc.rdoc >> >> James Edward Gray II >> >> > > Ok. I was unaware of that. But to_proc is more like to_ary than > to_a, IMO. (Not that I've ever seen a to_p ;) ). I could maybe go > for splat working on anything that responded to to_ary, but > currently it just personally feels kinda icky. Wish granted. ;) >> class ToAry >> undef to_a >> def to_ary >> [1, 2, 3] >> end >> end => nil >> arr = ToAry.new => # >> arr.respond_to? :to_a => false >> def show( one, two, three ) >> p one >> p two >> p three >> end => nil >> show(*arr) 1 2 3 => nil to_ary() is favored. Otherwise, to_a() is used. James Edward Gray II