From: Joel VanderWerf Date: 2006-12-02T04:08:58+09:00 Subject: Re: Simple iteration in a function problem Blake Miller wrote: ... > # this is the problem function. all I want is the specific (ONE) > element > # from the @ys array that matches the id, but when you iterate over the > # array, i can't find a way to only have one element returned > def getXById(id) Instead of: > @ys.each_with_index do |comp, index| > if( @ys[index].getUniqueId == id ) > @ys.fetch(index) > end > end try this: @ys.find {|x| x.getUniqueId == id} > end -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407