From: Jacob Fugal Date: 2006-10-12T05:36:31+09:00 Subject: Re: case ... when and arrays (or what was why_ showing us at On 10/11/06, Drew Olson wrote: > If you just want to check if the array contains that string somewhere, > can you just use: > > if foo =~ array.join(" ") > blah > else > blah2 > end Ah, but consider: array = [ "foo", "bar", "baz" ] foo = "foo bar" puts(foo =~ array.join(" ") ? "true" : "false") puts(array.include?(foo) ? "true" : "false") puts case foo when *array: "true" else "false" end produces: true false false The semantics are different. Your approach may be valid in some cases, I'm not discounting it altogether, but the two approaches do yield different results in the edge cases. Jacob Fugal