2008/9/24 Ittay Dror <ittay.dror / gmail.com>: > Thanks for the response, I was looking more to something along the lines of > Ola Bini's post > http://ola-bini.blogspot.com/2006/11/nooks-and-crannies-of-ruby.html. He > describes there that the splat operator works by first checking if the > object has a to_a which allows for some cool tricks. I believe this is not completely correct (see below). > What I want to know is > where he got this information from? (digging through the C code?) You can test this out yourself. 11:39:01 ~$ ./sp.rb ./sp.rb:7 [1, 2, 3] ./sp.rb:8 [[1, 2, 3]] ./sp.rb:9 [1..3] ./sp.rb:10 [1, 2, 3] ["to_a"] ./sp.rb:15 [#<Object:0x1002e274>] ./sp.rb:16 [#<Object:0x1002e274>] ./sp.rb:23 [#<Object:0x1002e274>] to_a ./sp.rb:24 ["to_a"] ./sp.rb:31 [#<Object:0x1002e274>] to_ary ./sp.rb:32 ["to_ary"] 11:39:03 ~$ cat sp.rb #!/bin/env ruby def t *a printf "%s %p\n", caller.first, a end t 1,2,3 t [1,2,3] t (1..3) t *(1..3) o = Object.new p o.methods.grep(/to_a/) t o t *o def o.to_a puts "to_a" ["to_a"] end t o t *o def o.to_ary puts "to_ary" ["to_ary"] end t o t *o 11:39:10 ~$ Kind regards robert -- use.inject do |as, often| as.you_can - without end