From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (smtp.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id BCC4C1B00023 for ; Tue, 20 Sep 2016 09:24:44 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 9FF8AB5D844 for ; Tue, 20 Sep 2016 09:56:55 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id DA32A18D173E for ; Tue, 20 Sep 2016 09:56:55 +0900 (JST) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id E00D012045E; Tue, 20 Sep 2016 09:56:54 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id 14DCA120419 for ; Tue, 20 Sep 2016 09:56:50 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=XFc8YfJCFU3AfLlkF2/3JpJFdJE=; b=r145eMvuJVYpRyrM0w 5PMbUle1EBIR016IUsRakWD4Egh8h2MJpSzV2bgWHyH2HQZpwBhVJ5tZ5xqQdyNp 0dMbCgHd1mvyiWsgj4aHYQmlrsixYl2v8Id0wUeXzoY2MO87LCteVn0RzWNe7FIc z1/hR49WbVsgJvfDfJ/UhEK20= Received: by filter0627p1mdw1.sendgrid.net with SMTP id filter0627p1mdw1.16398.57E0894D1B 2016-09-20 00:56:45.489649544 +0000 UTC Received: from herokuapp.com (ec2-107-21-179-177.compute-1.amazonaws.com [107.21.179.177]) by ismtpd0005p1iad1.sendgrid.net (SG) with ESMTP id Lgb3JSjsThS6JYtAeU4NJg for ; Tue, 20 Sep 2016 00:56:45.435 +0000 (UTC) Date: Tue, 20 Sep 2016 00:56:45 +0000 From: nobu@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 52146 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 12760 X-Redmine-Issue-Author: zverok X-Redmine-Sender: nobu X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS6xFix7JjOOGwgdBONHvuBErubTBibq6XpLR7 Z1sEQiAv48InfQlcryYe5T+riagSLZlod1muyDwj4qLQL+VuXeGtgjwViXBa6U8FLfZhOQNTTd8s9b efDEui6qfvHlK/uM72VpnBiNwp6unDgVdaxjr9FZ5buPUZzP54kzzVnvBw== X-ML-Name: ruby-core X-Mail-Count: 77318 Subject: [ruby-core:77318] [Ruby trunk Feature#12760] Optional block argument for `itself` X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #12760 has been updated by Nobuyoshi Nakada. What about `let` ?: ```ruby some.long.method.chain.constructing.string .let { |s| "(" + s + ")" } ``` ---------------------------------------- Feature #12760: Optional block argument for `itself` https://bugs.ruby-lang.org/issues/12760#change-60568 * 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/