From: Robert Klemme Date: 2007-06-22T07:05:04+09:00 Subject: Re: if == any item in an array On 21.06.2007 11:54, Mariusz P��kala wrote: > On 2007-06-21 09:17:24 +0900 (Thu, Jun), 12 34 wrote: >>> Give this code a shot. You almost had it -- the syntax you were >>> looking for was the leading splat "*" in front of the PhotoEndings and >>> MovieEndings in the branches of the case statement. >>> >> Thank you and all the others that answered. The array.include was what I >> was thinking too. But removing a couple of commas and adding a couple of >> astericks (splats) is nice. Ruby is great. >> >> I don't understand the meaning of the *. I imagine it comes from the >> wildcard usage. What do I look up in my books to understand this. > > When the splat-solution appeared here an alarm bell rung in my head: > If the array is small, like in this problem, everything is OK. But what > if the array is huge? > > I was wondering whether stack overflows could occur. I havent found > them, but the benchmark shows that .include?() is faster. If there are *many* choices you would probably choose another solution - namely creating a hash with file extensions as keys and lambdas as values that perform some operation. Kind regards robert