ruby 的 Enumerable 方法
grep
是===来判断是否存在符合条件的sub enumerable
c = IO.constantsc.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_object1 楼 fireDragonpzy 2012-02-23 Array.instance_methods