From: "David A. Black" Date: 2005-08-27T03:22:36+09:00 Subject: Re: ruby quiz question '*' on the initialize parameters Hi -- On Sat, 27 Aug 2005, Gaston Garcia 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 -- it creates an array out of whatever comes in, zero or more of them. You can also put it at the end of a composite arglist: class C def initialize(a,b,*c) end C.new(1,2,3,4,5) # a == 1, b == 2, c == [3,4,5] David -- David A. Black dblack@wobblini.net