Issue #16752 has been updated by sawa (Tsuyoshi Sawada).


To be precise, actually,

```ruby
class A
  FOO = 1
  private_constant :FOO
end  
```

is not two method calls; it is one assignment and one method call.

Besides that, I don't see that writing:

```ruby
class A
  const_set :FOO, 1, private: true
end
```

is any more concise than writing:


```ruby
class A
  FOO = 1; private_constant :FOO
end  
```

----------------------------------------
Feature #16752: :private param for const_set
https://bugs.ruby-lang.org/issues/16752#change-84883

* Author: bughit (bug hit)
* Status: Open
* Priority: Normal
----------------------------------------
Defining a private constant should not require two method calls.

You want to encourage private declarations because they communicate intent better and are easier to refactor, two statements discourage it.

Ideally there should be compact syntax for direct private declarations, but that's probably a difficult change.

But `const_set :FOO, 1, private: true` or `const_set :FOO, 1, :private` should be trivial



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>