[#66126] Creation/Conversion methods/functions table for Ruby types — SASADA Koichi <ko1@...>
Hi,
5 messages
2014/11/07
[#66248] [ruby-trunk - Feature #10423] [PATCH] opt_str_lit*: avoid literal string allocations — normalperson@...
Issue #10423 has been updated by Eric Wong.
3 messages
2014/11/13
[#66595] [ruby-trunk - Bug #10557] [Open] Block not given when the argument is a string — bartosz@...
Issue #10557 has been reported by Bartosz Kopinski.
3 messages
2014/11/30
[ruby-core:66202] [ruby-trunk - Feature #10482] [Feedback] Allow ignored items to vary in `Enumerable#chunk`.
From:
akr@...
Date:
2014-11-11 10:08:16 UTC
List:
ruby-core #66202
Issue #10482 has been updated by Akira Tanaka.
Status changed from Open to Feedback
The method has a form which is incompatible with your proposal: enum.chunk(initial_state) { |elt, state| ... }
However I deprecated the form (since Ruby 2.2), your porposal may be considerable in future.
----------------------------------------
Feature #10482: Allow ignored items to vary in `Enumerable#chunk`.
https://bugs.ruby-lang.org/issues/10482#change-49899
* Author: Tsuyoshi Sawada
* Status: Feedback
* Priority: Normal
* Assignee:
* Category:
* Target version:
----------------------------------------
In #5663, regarding a method proposed, Yehuda Katz's writes:
~~~
The only caveat is that it would be impossible to intentionally return nil here; suggestions welcome.
~~~
I would like to note here that the same problem exists with `Enumerable#chunk`. Currently, when the key value is `nil`, the corresponding items are thrown out. That may be useful sometimes, but sometimes, silently doing so causes a hard-to-detect bug. At least, there should be a way to change what is ignored (which would not break existing code using it), and ideally, nothing should be thrown out unless explicitly specified (which would break existing code).
I propose `Enumerable#chunk` to take an optional named parameter `ignore`, which switches what is ignored. When something other than `nil` is specified, then `nil` should not be ignored:
~~~ruby
[:foo1, :foo2, "bar", nil, nil].chunk(ignore: String){|e| e.class}
# => [[Symbol, [:foo1, :foo2]], [NilClass, [nil, nil]]]
~~~
When you don't want anything to be ignored, then the parameter should be set to something that does not appear in the receiver:
~~~ruby
[:foo1, :foo2, "bar", nil, nil].chunk(ignore: "nothing to ignore"){|e| e.class}
# => [[Symbol, [:foo1, :foo2]], [String, ["bar"]], [NilClass, [nil, nil]]]
~~~
--
https://bugs.ruby-lang.org/