From: Adam Shelly Date: 2006-01-10T03:46:44+09:00 Subject: Re: Iterator Fu Failing Me why not write a new iterator: it will probably be useful again sometime: module Enumerable def find_first_result each {|item| result = yield item; return result if result } nil end end irb(main):075:0> tokens = %w( adam codes in ruby ) => ["adam", "codes", "in", "ruby"] irb(main):076:0> classes = [/a/, /b/, /c/] => [/a/, /b/, /c/] irb(main):077:0> elements = tokens.map do |token| irb(main):078:1* classes.find_first_result {|kind| kind =~ token} irb(main):079:1> end => [0, 0, nil, 2] -Adam