Sanity check on File.dirname


#1

Hi,

I need a quick sanity check.

Excepting potential backslashes for the moment, aren’t these two
identical?

File.dirname(path).split(’/’)[0…-2].join(’/’)

File.dirname(File.dirname(path))

Dan


#2

Dan, they differ if the path isn’t nested deeply enough, for example
“/a/b”, “/c” or “d”.

Regards,
Pit