Tag: enumerable

有没有更简洁的方法在Ruby中调用外部方法?

这样做有更简洁的方法吗? # Given a directory containing subdirectories: foo, bar targets = [‘./foo’, ‘./bar’, ‘./free’] targets.map{ |d| Dir.exists? d } # => [ true, true, false ] 我希望能够做类似于proc的事情…它感觉更干净: # targets.map( Dir.exists? )