c = IO.constants c.grep(/SEEK/) #=> [:SEEK_SET, :SEEK_CUR, :SEEK_END] res = c.grep(/SEEK/) {|v| IO.const_get(v) } res #=> [0, 1, 2]
array.public_methods.grep(/^each_(.*)$/){ puts $1} #index #with_index #entry #slice #cons #with_object