D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7246 - Provide a simpler example for std.algorithm.remove
Summary: Provide a simpler example for std.algorithm.remove
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: Andrej Mitrovic
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2012-01-07 23:25 UTC by Jerry Quinn
Modified: 2014-08-18 15:52 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jerry Quinn 2012-01-07 23:25:31 UTC
Example for remove with predicate is the following:

int[] a = [ 1, 2, 3, 2, 3, 4, 5, 2, 5, 6 ];
assert(a[0 .. remove!("a == 2")(a).length] == [ 1, 3, 3, 4, 5, 5, 6 ]);

This example is confusing because the array is named 'a' and the predicate placeholder is also named 'a'.  Yes, reading the predicate blurb at the top says that 'a' is a predicate var, but if the example used 2 different names, it would at least alert the impatient reader about this assumption more clearly.  I suggest:

int[] r = [ 1, 2, 3, 2, 3, 4, 5, 2, 5, 6 ];
assert(r[0 .. remove!("a == 2")(r).length] == [ 1, 3, 3, 4, 5, 5, 6 ]);
Comment 2 github-bugzilla 2014-04-23 17:56:41 UTC
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/899155194ac1cdd208af5b3176213461a0644b21
Fix Issue 7246 - Provide a simpler example for std.algorithm.remove.

https://github.com/D-Programming-Language/phobos/commit/79903eb19956fb3145ffbeb8cc34e80cd76f7d0c
Merge pull request #2107 from AndrejMitrovic/Fix7246

Issue 7246 - Provide a simpler example for std.algorithm.remove.