ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:72341] [Ruby trunk - Feature #9451] Refinements and unary & (to_proc)
@ 2015-12-18  4:13 Joseph Jones
  0 siblings, 0 replies; only message in thread
From: Joseph Jones @ 2015-12-18  4:13 UTC (permalink / raw)
  To: Ruby developers; +Cc: ruby-core

[-- 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 --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-12-18  3:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-18  4:13 [ruby-core:72341] [Ruby trunk - Feature #9451] Refinements and unary & (to_proc) Joseph Jones

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).