From: Joseph Jones Date: 2015-12-17T21:13:20-07:00 Subject: [ruby-core:72341] [Ruby trunk - Feature #9451] Refinements and unary & (to_proc) --567387e0_1d9f6e5f_16c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Joseph Jones liked your message with Boxer. On December 5, 2015 at 20:13:= 48 MST, justcolin=40gmail.com wrote:Issue =239451 has been updated by Col= in =46ulton.Is there any update on this feature=3F 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:=60module Example refine S= tring do def pugs =22Pugs=21=22 end endendusing Exampleputs ('a'..'z').ma= p(&:pugs)=60I can understand why they currently do not work, but it leads= to uglier code.----------------------------------------=46eature =239451= : Refinements and unary & (to=5Fproc)https://bugs.ruby-lang.org/issues/94= 51=23change-55254* Author: Jan Lelis* Status: Assigned* Priority: Normal*= Assignee: Yukihiro Matsumoto----------------------------------------Not = sure if this is a bug or feature request:=7E=7E=7Erubyrequire 'minitest/a= utorun'require 'set'module ClassToProc refine Class do def to=5Fproc lamb= da=7B =7C*args=7C self.new(*args) =7D end endendusing ClassToProcdescribe= 'Class=23to=5Fproc' do it 'works when called directly' do Set.to=5Fproc=5B= =5B1,2=5D=5D.must=5Fequal Set=5B1,2=5D end it 'fails when called via ampe= rsand' do =5B=5B1,2=5D=5D.map(&Set).must=5Fequal =5BSet=5B1,2=5D=5D enden= d=7E=7E=7EThe second example errors with *NoMethodError: super: no superc= lass method =60to=5Fproc' for Set:Class*Would be great to have it, though= .-- https://bugs.ruby-lang.org/ --567387e0_1d9f6e5f_16c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Joseph Jones liked your message with Boxer.


= On December 5, 2015 at 20:13:48 MST, justcolin=40gmail.com wrote:
Issue =239451 has been update= d by Colin =46ulton.


Is there any update on this feature= =3F 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:=

=60
module Example
refine String do
def = pugs
=22Pugs=21=22
end
end
end

using Example

puts ('a'..'z').map(&:pugs)
=60

I can understand why they currently do not work, but it leads to uglier = code.

----------------------------------------
=46eature = =239451: Refinements and unary & (to=5Fproc)
https://bugs.ruby-lang.= org/issues/9451=23change-55254

* Author: Jan Lelis
* Stat= us: Assigned
* Priority: Normal
* Assignee: Yukihiro Matsumoto<= br />----------------------------------------
Not sure if this is a = bug or feature request:

=7E=7E=7Eruby
require 'minitest/a= utorun'
require 'set'

module ClassToProc
refine Cl= ass do
def to=5Fproc
lambda=7B =7C*args=7C self.new(*= args) =7D
end
end
end

using ClassToProc
describe 'Class=23to=5Fproc' do
it 'works when called di= rectly' do
Set.to=5Fproc=5B=5B1,2=5D=5D.must=5Fequal Set=5B1,2=5D=
end

it 'fails when called via ampersand' do
= =5B=5B1,2=5D=5D.map(&Set).must=5Fequal =5BSet=5B1,2=5D=5D
end
end
=7E=7E=7E

The second example errors with *NoMethodE= rror: super: no superclass method =60to=5Fproc' for Set:Class*

Would be great to have it, though.




--
https://bugs.ruby-lang.org/
--567387e0_1d9f6e5f_16c--