为什么chdir
自 ruby 1.8.1 以来 Pathname 的方法已过时?它有什么问题?
这个:
dir = Pathname('a')
dir.chdir do
...
end
比这更短且更具可读性:
dir = Pathname('a')
Dir.chdir(dir) do
...
end
它没有任何问题,Pathname
只是不是适合它的地方。
改为使用Dir.chdir
。
来源:http ://corelib.rubyonrails.org/classes/Pathname.html#M000633 (点击“[Source]”)