Project

General

Profile

Feature #17171

Why is the visibility of constants not affected by `private`?

Added by marcandre (Marc-Andre Lafortune) 2 months ago. Updated about 1 month ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:100016]

Description

class Foo
  def call_me
    # ...
  end

  private

  SOME_DATA = %i[...].freeze  # is public, why not private?

  def calc_stuff  # is private, ok.
    # ...
  end
end

It's probably a naive question, but why shouldn't SOME_DATA's visibility be private?

When writing gems, more often than not the constants that I write are not meant for public consumption. I find it redundant (and tiresome) to explicitly write private_constant :SOME_DATA.


Related issues

Related to Ruby master - Feature #16752: :private param for const_setOpenActions

Also available in: Atom PDF