From: Robert Klemme Date: 2005-10-25T21:38:56+09:00 Subject: Re: searching an array 2005/10/25, Ralph Smith : > > I have an array of classes source[] > > I can sort it like this > source.sort! { |x,y| x.fname <=> y.fname } > > If I print it out it is sorted by 'fname'. > > Now I would like to search it for different fnames but can't find an example of how to do that. > Can someone tell me how? source.find {|x| x.fname == "foo"} source.select {|x| x.fname == "foo"} HTH robert