开发者

Why was Pathname's chdir method obsoleted?

Why is Pathname's chdir method obsoleted since ruby 1.8.1? What is wrong with it?

This:

dir 开发者_开发知识库= Pathname('a')
dir.chdir do
  ...
end

is shorter and more readable than this:

dir = Pathname('a')
Dir.chdir(dir) do
  ...
end


Nothing is wrong with it, Pathname just wasn't the right place for it.

Use Dir.chdir instead.

Source: http://corelib.rubyonrails.org/classes/Pathname.html#M000633 (click "[Source]")


There's also FileUtils.cd('/', :verbose => true)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜