From: Daniel Carrera Date: 2003-01-15T08:33:01+09:00 Subject: Extracting elements from an array. Hello, I have a question about Enumerable#grep or perhaps Enumerable#map. I have an array and I want to extract the entries that follow certain criteria. I'd like to do something like: array.grep { |x| valid?(x) } or array.map { |x| valid(x) ? x : return } valid?() returns true or false depending on whether the input meets the criteria. In my particular problem I have an array of the form: [ [ 34, "something" ] , [ 2, "another"] , ... ] I wish to eliminate the entries whose numeric value is less than - say - 3. So something like: array.map { |x| x < 3 ? return : x } would be nice. I haven't figured out how to do this with either grep or map. Can anyone offer some advice? Thanks a lot, Daniel Carrera Graduate Teaching Assistant. Math Dept. University of Maryland. (301) 405-5137