Project

General

Profile

Actions

Feature #17171

closed

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

Added by marcandre (Marc-Andre Lafortune) about 4 years ago. Updated about 4 years ago.

Status:
Rejected
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 1 (1 open0 closed)

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

Also available in: Atom PDF

Like1
Like0Like0Like0Like0Like1Like0Like0Like0Like0Like0Like0Like0Like0