From: Joseph Jones <joeyi5216@gmail.com>
To: Ruby developers <ruby-core@ruby-lang.org>
Cc: <ruby-core@ruby-lang.org>
Subject: [ruby-core:72341] [Ruby trunk - Feature #9451] Refinements and unary & (to_proc)
Date: Thu, 17 Dec 2015 21:13:20 -0700 [thread overview]
Message-ID: <9B941B52-C450-4C0B-AE0C-8BA4CBC1D32F@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1335 bytes --]
Joseph Jones liked your message with Boxer. On December 5, 2015 at 20:13:48 MST, justcolin@gmail.com wrote:Issue #9451 has been updated by Colin Fulton.Is there any update on this feature? In Ruby 2.2.3 I still run into a problem where the unary & can not be used when the method was added with a refinement, such as the following:`module Example refine String do def pugs "Pugs!" end endendusing Exampleputs ('a'..'z').map(&:pugs)`I can understand why they currently do not work, but it leads to uglier code.----------------------------------------Feature #9451: Refinements and unary & (to_proc)https://bugs.ruby-lang.org/issues/9451#change-55254* Author: Jan Lelis* Status: Assigned* Priority: Normal* Assignee: Yukihiro Matsumoto----------------------------------------Not sure if this is a bug or feature request:~~~rubyrequire 'minitest/autorun'require 'set'module ClassToProc refine Class do def to_proc lambda{ |*args| self.new(*args) } end endendusing ClassToProcdescribe 'Class#to_proc' do it 'works when called directly' do Set.to_proc[[1,2]].must_equal Set[1,2] end it 'fails when called via ampersand' do [[1,2]].map(&Set).must_equal [Set[1,2]] endend~~~The second example errors with *NoMethodError: super: no superclass method `to_proc' for Set:Class*Would be great to have it, though.-- https://bugs.ruby-lang.org/
[-- Attachment #2: Type: text/html, Size: 2004 bytes --]
reply other threads:[~2015-12-18 3:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9B941B52-C450-4C0B-AE0C-8BA4CBC1D32F@gmail.com \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).