Skip to content

Commit

Permalink
Fix issue 15735: Correct splitter documentation when argument is an e…
Browse files Browse the repository at this point in the history
…mpty range.
  • Loading branch information
jondegenhardt committed Oct 8, 2017
1 parent 29a629e commit c6ef7c3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions std/algorithm/iteration.d
Expand Up @@ -3663,9 +3663,8 @@ empty elements.
The predicate is passed to $(REF binaryFun, std,functional), and can either accept
a string, or any callable that can be executed via $(D pred(element, s)).
If the empty range is given, the result is a range with one empty
element. If a range with one separator is given, the result is a range
with two empty elements.
If the empty range is given, the result is an empty range. If a range with
one separator is given, the result is a range with two empty elements.
If splitting a string on whitespace and token compression is desired,
consider using $(D splitter) without specifying a separator (see fourth overload
Expand Down Expand Up @@ -3852,6 +3851,7 @@ if (is(typeof(binaryFun!pred(r.front, s)) : bool)
@safe unittest
{
import std.algorithm.comparison : equal;
import std.range : empty;

assert(equal(splitter("hello world", ' '), [ "hello", "", "world" ]));
int[] a = [ 1, 2, 0, 0, 3, 0, 4, 5, 0 ];
Expand All @@ -3863,6 +3863,8 @@ if (is(typeof(binaryFun!pred(r.front, s)) : bool)
assert(equal(splitter(a, 0), [ [], [1] ]));
w = [ [0], [1], [2] ];
assert(equal(splitter!"a.front == b"(w, 1), [ [[0]], [[2]] ]));
assert(splitter("", '.').empty);
assert(equal(splitter(".", '.'), [ "", "" ]));
}

@safe unittest
Expand Down

0 comments on commit c6ef7c3

Please sign in to comment.