Sanity check on File.dirname

D

Daniel Berger

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
 
P

Pit Capitain

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

Regards,
Pit
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,183
Messages
2,570,966
Members
47,515
Latest member
Harvey7327

Latest Threads

Top