From: sawadatsuyoshi@... Date: 2016-02-20T15:34:58+00:00 Subject: [ruby-core:73902] [Ruby trunk Feature#12079] Loosening the condition for refinement Issue #12079 has been updated by Tsuyoshi Sawada. To the list of relevant constructions, I would also like to add `inject` when it takes a symbol argument. ~~~RUBY module Foo refine String do def baz a, b; a + b * 2 end end end using Foo ["x", "y", "z"].inject(:baz) # => undefined method error ["x", "y", "z"].inject("", :baz) # => undefined method error ~~~ So my generalization for the target of my proposal is: Ruby core methods in which a(nother) method is called in the form of a symbol. There may be a few more of them that I have missed. ---------------------------------------- Feature #12079: Loosening the condition for refinement https://bugs.ruby-lang.org/issues/12079#change-57063 * Author: Tsuyoshi Sawada * Status: Open * Priority: Normal * Assignee: ---------------------------------------- There are a few non-standard ways of calling a method that cannot be used when the relevant method is a refined method: * a symbol used with `&` as a block via symbol to proc * a symbol used with `send` or `__send__` For example, the following will fail: ~~~RUBY module Foo refine String def baz; end end end using Foo ["a", "b", "c"].map(&:baz) # => undefined method error "a".send(:baz) # => undefined method error ~~~ I would like to propose to loosen the condition for refinement so that as long as the relevant construction (such as the use of `&` to provoke `Symbol#to_proc` or calling of `send` or `__send__`) is within the valid scope of refinement, allow the call to the relevant methods. -- https://bugs.ruby-lang.org/ Unsubscribe: