From: zverok.offline@... Date: 2016-09-14T07:39:37+00:00 Subject: [ruby-core:77267] [Ruby trunk Feature#12760] Optional block argument for `itself` Issue #12760 has been reported by Victor Shepelev. ---------------------------------------- Feature #12760: Optional block argument for `itself` https://bugs.ruby-lang.org/issues/12760 * Author: Victor Shepelev * Status: Open * Priority: Normal * Assignee: ---------------------------------------- That's an another attempt to choose good metaphor for `object.(yield self)` (previously: #6721 and ton of duplicates). In discussion here: https://bugs.ruby-lang.org/issues/11717#note-3 it was said: > Clearly this is something the Ruby community wants. Just as clearly, it's something nobody can name. But suddenly... I've thought about this! ```ruby some.long.method.chain.constructing.string .itself { |s| "(" + s + ")" } .itself(&method(:puts)) # or require 'open-uri' construct_url(*params) .itself(&method(:open)) .read .itself(&JSON.method(:parse)) .to_yaml .itself(&File.method(:write)) # NB: I understand that _last_ `itself` in both examples # could as well be `tap`. But not all the previous. ``` Pros: * method is already here, it has pretty name and underused (almost nothing except `group_by(&:itself)` comes to mind); * it is not 100% good English, but readable: `itself(&JSON.method(:parse))` = "parse itself with json"; * implementation is trivial, no backwards-compatibility issues (like new methods shadowing something important in third-party library) are expected. Cons: * ??? -- https://bugs.ruby-lang.org/ Unsubscribe: