[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Sanity check on File.dirname

Daniel Berger

2/10/2009 8:05:00 PM

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

1 Answer

Pit Capitain

2/11/2009 9:22:00 AM

0

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

Regards,
Pit