Project

General

Profile

Actions

Feature #17171

closed

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

Added by marcandre (Marc-Andre Lafortune) over 3 years ago. Updated over 3 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

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0