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_object

我们摇摇头说,困难其实没什么大不了。

ruby 的 Enumerable 方法

相关文章:

你感兴趣的文章:

标签云: