From: Ryan Davis Date: 2008-11-22T04:53:21+09:00 Subject: Re: How to use include? on an array of objects On Nov 21, 2008, at 09:44 , Fernando Perez wrote: > I have the following array: > > [ product1, product2, product3 ] > > All products are of type Product. The Product class defines isntance > attributes such as: title, description, price. > > Can I use include? to check if the array has a product which price is > zero? if not what would I need to do? Iterate over each product and > set > a variable if a match is found? c'mon guys... teach a man to fish. Fernando, check out ri. ri is your friend(tm). % ri Array % ri Enumerable (Array includes Enumerable). There is a LOT of good stuff in Enumerable. You should poke around and learn as much of it as you can: % ri Enumerable.find % ri Enumerable.find_all etc. Other places to look are http://ruby-doc.org/ and the PragProg pickaxe book (Programming Ruby, 2nd ed).