On Tuesday, 31 December 2013 at 21:23:08 UTC, Rémy Mouëza wrote:
I'd also suggest the following alternative, if you're going to
discard a lot of last elements in your code:
/// Return seq without its last element.
auto poppedBack (T) (T seq) if (isInputRange!T) {
seq.popBack; // Discards the last element.
return seq;
}
That's a function in "std.range": dropBack. No need for this.
On Wednesday, 1 January 2014 at 07:36:11 UTC, Dfr wrote:
This is interesting, why i can't just do it simpler way ?
"this.is.a.string"
.splitter (".")
.popBack
.joiner (".")
.array
.writeln;
Because creating an extra function is not desired.
Because "popBack" is not the same as (the oddly named)
"poppedBack". "drop" will do what you need, without a new
function.