From: Chad Fowler Date: 2008-12-01T21:40:03+09:00 Subject: Re: How do you find an item that satisfies multiple conditions? On Mon, Dec 1, 2008 at 6:34 AM, Bob Sanders wrote: > I know that to find an item that satisfies one condition, it's this: > > @items.find {|item| item.product == product } > > I thought I could try this to check that an item satisfies multiple > conditions: > > @items.find {|item| > item.product == product > item.red == red > item.blue == blue > } > Hi Bob. The find method returns a new collection including all elements for which the block returns boolean true. In this case, your product and red comparisons happen but are not returned from the block and are ignored. Whaty ou want is ONE boolean expression combining all of these comparisons: @items.find{|item| item.product == product && item.red == red && item.blue == blue } Chad