Issue #9071 has been updated by Akira Tanaka.

File slice_after.patch added
Assignee set to Akira Tanaka

I impelemented Enumerable#slice_after.

I found two request for this feature:
This issue and
http://stackoverflow.com/questions/22622156/how-to-implement-slice-after-or-group-certain-elements-with-certain-subsequent

I wrote the document with an example follows:

```
% ./ruby -e '
lines = ["foo\n", "bar\\\n", "baz\n", "\n", "qux\n"]
e = lines.slice_after(/(?<!\\)\n\z/)
p e.to_a
p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last }'
[["foo\n"], ["bar\\\n", "baz\n"], ["\n"], ["qux\n"]]
["foo\n", "barbaz\n", "\n", "qux\n"]
```

This concatenates continuation lines.

More useful (catchy) examples may be helpful to persuade matz.

Any idea?


----------------------------------------
Feature #9071: Enumerable#slice_after
https://bugs.ruby-lang.org/issues/9071#change-46659

* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee: Akira Tanaka
* Category: 
* Target version: 
----------------------------------------
I see in this discussion: http://ruby.11.x6.nabble.com/ruby-dev-38392-Enumerable-gather-each-td3534746.html that `Enumerable#slice_before` was named as such, having in mind the possibility of `Enumerable#slice_after` being implemented in the future. I feel the former convenient, but believe the latter should be as well, and am wondering why the latter was not implemented at the same time. I request it to be implemented.

---Files--------------------------------
slice_after.patch (7.01 KB)


-- 
https://bugs.ruby-lang.org/