Programming-Idioms

History of Idiom 151 > diff from v4 to v5

Edit summary for version 5 :
[Ruby] Misread question

Version 4

2016-10-26, 12:13:00

Version 5

2016-10-26, 13:48:44

Idiom #151 Remove string trailing path separator

Remove last character from string p, if this character is the file path separator of current platform.

Note that this also transforms unix root path "/" into empty string!

Idiom #151 Remove string trailing path separator

Remove last character from string p, if this character is the file path separator of current platform.

Note that this also transforms unix root path "/" into empty string!

Code
p.chomp!
Code
p.chomp!("/")
Comments bubble
Ruby uses _/ as path separator on all platforms, including windows.