< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Issue #15588 has been updated by naruse (Yui NARUSE).
This requires more concrete real world example.
----------------------------------------
Feature #15588: String#each_chunk and #chunks
https://bugs.ruby-lang.org/issues/15588#change-76696
* Author: Glass_saga (Masaki Matsushita)
* Status: Open
* Priority: Normal
* Assignee:
* Target version: 2.7
----------------------------------------
String#each_chunk iterates chunks of specified size in String.
String#chunks is a shorthand for str.each_chunk(n).to_a.
present:
```ruby
str = <<EOS
20190101 20190102
20190103 20190104
EOS
str.scan(/.{1,9}/m) do |chunk|
p chunk #=> "20190101 "
end
str.scan(/.{1,9}/m) do |chunk|
chunk.strip!
p chunk #=> "20190101"
end
str.scan(/.{1,9}/m) #=> ["20190101 ", "20190102\n", "20190103 ", "20190104\n"]
str.scan(/.{1,9}/m).map(&:strip) #=> ["20190101", "20190102", "20190103", "20190104"]
```
proposal:
```ruby
str = <<EOS
20190101 20190102
20190103 20190104
EOS
str.each_chunk(9) do |chunk|
p chunk #=> "20190101 "
end
str.each_chunk(9, strip: true) do |chunk|
p chunk #=> "20190101"
end
str.chunks(9) #=> ["20190101 ", "20190102\n", "20190103 ", "20190104\n"]
str.chunks(9, strip: true) #=> ["20190101", "20190102", "20190103", "20190104"]
```
---Files--------------------------------
patch.diff (6.56 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>