Programming-Idioms

History of Idiom 151 > diff from v8 to v9

Edit summary for version 9 :
New D implementation by user [Bzzzzzzzz]

Version 8

2016-11-09, 17:51:42

Version 9

2017-07-26, 09:34:58

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!

Imports
import std.string,
import std.ascii;
Code
p = p.chomp(newLine);
Comments bubble
By default chomp removes all line separator, regardless of the platform so we specify a platform-specific value.
Doc URL
https://dlang.org/phobos/std_string.html#.chomp