Task to throw away string parts, use joiner and splitter not very successful

monarch_dodra monarchdodra at gmail.com
Thu Jan 2 07:36:41 PST 2014


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.


More information about the Digitalmars-d-learn mailing list