require'minitest/autorun'require'set'moduleClassToProcrefineClassdodefto_proclambda{|*args|self.new(*args)}endendendusingClassToProcdescribe'Class#to_proc'doit'works when called directly'doSet.to_proc[[1,2]].must_equalSet[1,2]endit'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
As #=== from case statement and #each from for statement, I think refinement should be effective to methods that called implicitly. Let us discuss about the issue.
As #=== from case statement and #each from for statement, I think refinement should be effective to methods that called implicitly. Let us discuss about the issue.
What do you think of other implicit conversions such as to_a called by the splat operator.
Assignee changed from shugo (Shugo Maeda) to matz (Yukihiro Matsumoto)
Target version set to 2.2.0
I'd like to clarify the design policy rather than adding features ad hoc.
All implicit method calls in syntactic constructs should be affected by refinements, right?
Do other implementers, especially JRuby people, accept this policy?
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: