[#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 upgraded (to 2.1.0.pre.1).
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.
[ruby-core:92772] [Ruby trunk Feature#15831] Add `Array#extract`, `Hash#extract`, and `ENV.extract`
From:
matz@...
Date:
2019-05-22 07:45:39 UTC
List:
ruby-core #92772
Issue #15831 has been updated by matz (Yukihiro Matsumoto).
Status changed from Open to Rejected
I don't think we have seen the use-case that this method is absolutely necessary. I also concern about the name conflict with the ActiveSupport method.
Let me see the real-world use-case, please.
Matz.
----------------------------------------
Feature #15831: Add `Array#extract`, `Hash#extract`, and `ENV.extract`
https://bugs.ruby-lang.org/issues/15831#change-78137
* Author: bogdanvlviv (Bogdan Denkovych)
* Status: Rejected
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
## Add `Array#extract`
The method removes and returns the elements for which the block returns a true value.
If no block is given, an Enumerator is returned instead.
```ruby
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
odd_numbers = numbers.extract { |number| number.odd? } # => [1, 3, 5, 7, 9]
numbers # => [0, 2, 4, 6, 8]
```
This method was added to Active Support as `extract!` in https://github.com/rails/rails/pull/33137
In this post, you can find use cases of this method
https://bogdanvlviv.com/posts/ruby/rails/array-extract-to-activesupport-6-0.html
## Add `Hash#extract`
The method removes and returns the key/value pairs for which the block evaluates to +true+.
If no block is given, an Enumerator is returned instead.
```ruby
h = {a: 100, b: 200, c: 300}
h.extract {|k, v| v > 150} # => {:b=>200, :c=>300}
h # => {:a=>100}
```
Note that there is method `extract!` in Active Support that was added in 2009, see
https://github.com/rails/rails/commit/8dcf91ca113579646e95b0fd7a864dfb6512a53b
But I think we should upstream `extract!` to Ruby as `slice!`.
## Add `ENV.extract`
The method removes and returns the key/value pairs for which the block evaluates to +true+.
If no block is given, an Enumerator is returned instead.
```ruby
ENV.extract {|k, v| k == "PORT"} # => {"PORT"=>"3000"}
```
Pull Request: https://github.com/ruby/ruby/pull/2171
Patch: https://patch-diff.githubusercontent.com/raw/ruby/ruby/pull/2171.patch
--
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>