Project

General

Profile

Actions

Bug #18826

closed

Symbol#to_proc inconsistent, sometimes calls private methods

Added by bjfish (Brandon Fish) over 2 years ago. Updated over 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:108882]

Description

The following usage calls a protected method and prints "hello":

class Test
    protected

    def referenced_columns
        puts "hello"
    end
end      
Test.new.tap(&:referenced_columns)

However, the following usage results in a NoMethodError:

class Integer
    private
    def foo
      42
    end
  end

(1..4).collect(&:foo)

It seems to be a bug that tap calls a private method. It is also inconsistent with collect not calling private methods.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0