On 8/26/05, Gaston Garcia <gaston.garcia / gmail.com> wrote:
> Hi everyone:
> 
> On the ruby quiz called: Banned Words (#9), I'm looking at the class posted
> there and I came up with something I had never seen before (probably because
> I'm really new to Ruby)
> 
> class LanguageFilter
>  def initialize( *banned_words )
>  @banned_words = banned_words.flatten.sort
>  @clean_calls = 0
>  end
> 
> end
> 
> I had never seen this:
> 
> def initialize(*banned_words)
> 
> what does that * do? Does it mean I can send as many parameters as I want?


Yes.  And it sticks them into an array.

-bash-2.05b$ cat a.rb
def foo *args
  p args
end
foo 1, 2, 3, 4, 5, [6, 7]



-bash-2.05b$ ruby a.rb
[1, 2, 3, 4, 5, [6, 7]]

Hope that makes sense.