From: Terry Michaels Date: 2010-09-10T13:27:21+09:00 Subject: Re: Receiving array naturally? Clifford Heath wrote: > Terry Michaels wrote: >> Clifford Heath wrote: >>> You've overlooked the simplest way: >> That doesn't work, because an array passed it gets treated like simply >> an element of the "strings" array: > > Ah, right you are. I was thinking of this: > > Array([2]) => [2] > Array(2) => [2] > but Array(*[1,2,3]) => ArgumentError: wrong number of arguments (3 for > 1) > > ... and yes, I left out the *. > What I was thinking of was Array[*strings] > > However (I knew I'd done something like this before!): > > def process_data(*strings) > strings = *strings > strings.each do |s| > print s.class.to_s + " " + s.to_s + " " + "\n" > end > end > > process_data("a", "b", "c") > process_data(["a", "b", "c"]) > > Does what you want. > > Clifford Heath. This seems to work. If I might ask, what exactly is the line strings = *strings doing? For that matter, I could use a little more clarification on what the '*' (glob?) operator does... -- Posted via http://www.ruby-forum.com/.