[#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:92621] [Ruby trunk Feature#15829] Object#then_if(condition){}
From:
sawadatsuyoshi@...
Date:
2019-05-11 12:11:17 UTC
List:
ruby-core #92621
Issue #15829 has been updated by sawa (Tsuyoshi Sawada).
I have exactly the same concern as nobu. And that problem stems from the fact that, in this proposal, the condition is given as an argument of the method, which means that it has to be evaluated independently of the return value that appears in the middle of the method chain.
That should take us back to #15547, where the condition is proposed to be given as a block (or proc, in a comment).
----------------------------------------
Feature #15829: Object#then_if(condition){}
https://bugs.ruby-lang.org/issues/15829#change-77980
* Author: foonlyboy (Eike Dierks)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
I'd like to propose some sugar to Object#then
There should be `Object#then_if(condition, &block)`
The block should only be applied when the condition is true,
otherwise the object should be returned without applying the block.
Rationale:
I frequently use `Object#then` with Rails to extend queries like this:
```ruby
foo.then {|query|
if(condition)
query.where(zip:zap)
else
query
end
}
```
by using the proposed `Object#then_if` the example could be simplified to:
```ruby
foo.then_if(condition) {|query|
query.where(zip:zap)
}
```
I believe that this also applies to a lot of other use cases,
i.e. only applying some transformation if some condition is true,
but otherwise leaving the result untouched.
--
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>