[#92891] Question: ruby 2.7.0-preview1 also upgrades bundler to 2.1.0.pre.1? — Al Snow <jasnow@...>
Tried the new 2.7.0-preview1 upgrade to Ruby and see that bundler is also u=
5 messages
2019/05/30
[#92892] Re: Question: ruby 2.7.0-preview1 also upgrades bundler to 2.1.0.pre.1?
— SHIBATA Hiroshi <hsbt@...>
2019/05/30
Bundler 2.1.0.pree.1 is the expected version.
[#92893] Re: Question: ruby 2.7.0-preview1 also upgrades bundler to 2.1.0.pre.1?
— Al Snow <jasnow@...>
2019/05/30
[ruby-core:92605] [Ruby trunk Feature#11797] `Enumerator#with_object` with multiple objects
From:
sawadatsuyoshi@...
Date:
2019-05-09 06:21:29 UTC
List:
ruby-core #92605
Issue #11797 has been updated by sawa (Tsuyoshi Sawada).
I now realize that, for the given use case, I can use `with_object` multiple times as follows:
```ruby
e
.each.with_object({}).with_object([]) {|(c, h), a| h[c] ? a.push(c) : h.store(c, true)}
.uniq
```
So I withdraw this feature request. Please close it.
----------------------------------------
Feature #11797: `Enumerator#with_object` with multiple objects
https://bugs.ruby-lang.org/issues/11797#change-77964
* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Sometimes, when working with `Enumerator#with_object`, I want to keep some additional temporary objects besides the one to return. A use case is as follows (I got this from this StackOverflow question: http://stackoverflow.com/questions/3418123). Suppose I have an enumerator created from an array:
e = ["a", "b", "c", "c", "a", "c"].to_enum
and want to get an array of its repeated elements in the order they are repeated (i.e., appears for the second time):
# => ["c", "a"]
I can do it using `Enumerator#with_object` like this:
e.to_enum.with_object([{}, []]){|c, (h, a)| h[c] ? a.push(c) : h.store(c, true)}.last.uniq
Here, I am getting the array referred to as `a` in the block, but besides that, I am using a temporal hash `h`. I thought it would be nice if `Enumerator#with_object` accepts one or more objects, pass them individually as block arguments, and returns only the last argument so that I can do this:
e.to_enum.with_object({}, []){|c, h, a| h[c] ? a.push(c) : h.store(c, true)}.uniq
--
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>