From: Hal Fulton Date: 2004-09-23T07:58:08+09:00 Subject: Re: Newbie: Case statement Graham Foster wrote: > As a newbie I'm confused about the Case construct. All the > documentation I've found states "case operates by comparing the > target with EACH of the expressions after the When keyword" > This does NOT appear to happen, as only the first match is ever > actioned, so overlapping WHEN cases are skipped. "Each" but only "until a match." > I assume this is expected behaviour? (I'm ex-C - and was looking for > fall-through behaviour) It's a strict multi-way branch; there's no fall-through from one limb to another. > So my underlying question is:- what's the fastest Ruby for checking > which of the 8 possible adjacent cells on a board (2D array) are > still "on the board" I'm not sure I grasp what you mean. But you *might* try something like this: ranges = {a..b=>"A",c..d=>"B",e..f=>"C",g..h=>"D",i..j=>"E"] # looking for 'target' list = ranges.reject {|x| ! x.include?(target) } list = list.values p list Hal