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_object
我们摇摇头说,困难其实没什么大不了。