From: zverok.offline@... Date: 2017-05-26T21:37:26+00:00 Subject: [ruby-core:81403] [Ruby trunk Feature#13601] Remove yield_self from Ruby 2.5 (already implemented) Issue #13601 has been updated by zverok (Victor Shepelev). `instance_eval` changes scope, while `yield_self` does not. ```ruby class A def foo 1 end def yield_self yield self end end def self.foo 2 end p A.new.instance_eval { self.foo * 3 } # => 3 p A.new.yield_self { self.foo * 3 } # => 6 ``` An example is synthetic, yet the difference is important. ...and was discussed multiple times on the road to `yield_self`, to be honest. ---------------------------------------- Feature #13601: Remove yield_self from Ruby 2.5 (already implemented) https://bugs.ruby-lang.org/issues/13601#change-65112 * Author: danielpclark (Daniel P. Clark) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Issue https://bugs.ruby-lang.org/issues/6721 for adding `yield_self` is unnecessary as `BasicObject#instance_eval` will do the exact same thing. ~~~ruby class BasicObject alias :yield_self :instance_eval end 2.yield_self { |x| x*x } # => 4 ~~~ I've tried all the examples of its given use cases and `BasicObject#instance_eval` will do them all. In issue #6721 nobu said he didn't like the name `yield_self`. I'm in agreement about the name. Since `BasicObject#instance_eval` will already pipe in `self` and return the value of the block `yield_self` is not necessary. -- https://bugs.ruby-lang.org/ Unsubscribe: