[#81999] [Ruby trunk Bug#13737] "can't modify frozen String" when installing bundled gems — ko1@...
Issue #13737 has been updated by ko1 (Koichi Sasada).
4 messages
2017/07/11
[#82005] [Ruby trunk Bug#13737] "can't modify frozen String" when installing bundled gems — nobu@...
Issue #13737 has been updated by nobu (Nobuyoshi Nakada).
3 messages
2017/07/12
[#82102] Re: register_fstring_tainted:FL_TEST_RAW(str, RSTRING_FSTR) — Eric Wong <normalperson@...>
Koichi Sasada <ko1@atdot.net> wrote:
4 messages
2017/07/18
[#82151] [Ruby trunk Feature#13637] [PATCH] tool/runruby.rb: test with smallest possible machine stack — Rei.Odaira@...
Issue #13637 has been updated by ReiOdaira (Rei Odaira).
3 messages
2017/07/24
[ruby-core:82210] [Ruby trunk Feature#13777] Array#delete_all
From:
takashikkbn@...
Date:
2017-07-30 07:12:03 UTC
List:
ruby-core #82210
Issue #13777 has been reported by k0kubun (Takashi Kokubun).
----------------------------------------
Feature #13777: Array#delete_all
https://bugs.ruby-lang.org/issues/13777
* Author: k0kubun (Takashi Kokubun)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
I want Array#delete_if which returns array of deleted values.
For following code,
~~~
array = ["a", "aa", "ab", "bb", "c"]
result = {}
until array.empty?
key = array.first
group, array = array.partition { |v| v.start_with?(key) }
result[key] = group
end
result #=> {"a"=>["a", "aa", "ab"], "bb"=>["bb"], "c"=>["c"]}
~~~
With Array#delete_all, This would be able to be written in more elegant way like:
~~~
array = ["a", "aa", "ab", "bb", "c"]
result = {}
until array.empty?
key = array.first
result[key] = array.delete_all { |v| v.start_with?(key) }
end
result #=> {"a"=>["a", "aa", "ab"], "bb"=>["bb"], "c"=>["c"]}
~~~
This is simplified source code of real use case in Haml: https://github.com/haml/haml/blob/923a0d78874fe1d369f8c7a0bf77f67b2c2139bb/lib/haml/attribute_compiler.rb#L75-L76
This grouping task is necessary for Haml optimization.
Do you know simpler way to write this with existing methods?
--
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>