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 (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 4260617D2FB0 for ; Sun, 1 Sep 2013 06:01:54 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (smtp.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 83AC7B5D82B for ; Sun, 1 Sep 2013 05:32:16 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 10B9E97A82C for ; Sun, 1 Sep 2013 05:32:17 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OWk7BsEN-rxU for ; Sun, 1 Sep 2013 05:32:16 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id E415197A82B for ; Sun, 1 Sep 2013 05:32:16 +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 2710B95243A for ; Sun, 1 Sep 2013 05:32:15 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 45F2F114D5E; Sun, 1 Sep 2013 05:32:06 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from fluorine.ruby-lang.org (fluorine.ruby-lang.org [210.251.121.216]) by neon.ruby-lang.org (Postfix) with ESMTP id AF73B1204A5 for ; Sun, 1 Sep 2013 05:32:03 +0900 (JST) Received: from ruby-lang.org (localhost [127.0.0.1]) by fluorine.ruby-lang.org (Postfix) with ESMTP id 8C8802920F for ; Sun, 1 Sep 2013 05:32:03 +0900 (JST) Date: Sun, 1 Sep 2013 05:32:03 +0900 From: "alexeymuranov (Alexey Muranov)" To: ruby-core@ruby-lang.org Message-Id: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Redmine-Issue-Author: alexeymuranov X-Redmine-Issue-Assignee: matz X-Auto-Response-Suppress: OOF X-Redmine-Issue-Id: 6721 X-Redmine-Mailinglistintegration-Message-Ids: 30515 X-Mailer: Redmine X-Redmine-Project: ruby-trunk Auto-Submitted: auto-generated X-Redmine-Site: Ruby Issue Tracking System X-Redmine-Host: bugs.ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 56950 Subject: [ruby-core:56950] [ruby-trunk - Feature #6721] Object#yield_self 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: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #6721 has been updated by alexeymuranov (Alexey Muranov). =begin Another idea for the name: (({Object#cast})), by analogy with typecasting or cast iron. Iron (an object) is poured into a mold (a proc or a block). class Object def cast(*args, &block) if block.nil? p = args.shift if p.is_a?(Proc) p[self, *args] else raise 'The first argument of Object#cast should be a Proc, unless a block form is used.' end else if args.empty? block[self] else raise 'Object#cast does not accept arguments together with a block.' end end end end 2.cast {|x| x**3 } # => 8 p = proc {|x, y| x**y } 2.cast(p, 4) # => 16 =end ---------------------------------------- Feature #6721: Object#yield_self https://bugs.ruby-lang.org/issues/6721#change-41509 Author: alexeymuranov (Alexey Muranov) Status: Open Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: next minor =begin I think the following method is missing from Ruby: class Object def yield_self(*args) yield(self, *args) end end I do not know a good use case, but it looks very natural to me. It can be used in method chains. What do you think? Is there an alternative? =end -- http://bugs.ruby-lang.org/