Bug 18341 – Documentation for std.array.split is confusing/incorrect

Status
RESOLVED
Resolution
FIXED
Severity
trivial
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
x86_64
OS
Other
Creation time
2018-01-31T03:25:27Z
Last change time
2018-02-24T11:36:34Z
Keywords
pull
Assigned to
No Owner
Creator
bachmeil

Comments

Comment #0 by bachmeil — 2018-01-31T03:25:27Z
The documentation says "Eagerly split the string s into an array of words, using whitespace as delimiter." Then under See Also it says "std.algorithm.iteration.splitter for a version that splits using any separator." Then one of the examples shows how to use split with a user-specified separator: writeln(split("hello world")); // ["hello", "world"] writeln(split("192.168.0.1", ".")); // ["192", "168", "0", "1"] auto a = split([1, 2, 3, 4, 5, 1, 2, 3, 4, 5], [2, 3]); writeln(a); // [[1], [4, 5, 1], [4, 5]] Something has to be wrong. 1. I think the last example is intended to be used with the other version of split. 2. I don't understand why the user is referred to splitter when split can be used with any separator. AFAICT, the difference between split and splitter is that split is eager and splitter is lazy, and it has nothing to do with specifying the separator. 3. The statement "split allocates memory, so the same effect can be achieved lazily using std.algorithm.iteration.splitter." should not be located inside an example.
Comment #1 by greensunny12 — 2018-02-19T18:36:19Z
Comment #2 by github-bugzilla — 2018-02-24T11:36:34Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/1956daf34f8779779a1d393e1870e275a0619b2e Fix Issue 18341 - Documentation for std.array.split is confusing/incorrect https://github.com/dlang/phobos/commit/d487bec91f3e2505df99284cd6fbe669f26afa73 Merge pull request #6200 from wilzbach/fix-18341 Fix Issue 18341 - Documentation for std.array.split is confusing/incorrect merged-on-behalf-of: Jack Stouffer <[email protected]>