There was a proposal on the Ruby bug tracker a while back about making the private method work also on constants: See https://bugs.ruby-lang.org/issues/17171 That proposal is now closed with concerns about backward compatibility. We should reopen th...

Markdown supported · ⌘↵ to post
Mitch Kuppinger
Parent (Grand), Physician, Programmer
For a long time I believed placing a constant below the private method actually made it private. Then I set a 'private' constant in a class where was no reason to use that constant outside of the class... But naming is hard and memory is not perfect so I used the same constant name elsewhere. I forgot it existed as a not 'private' constant in another class. Bang!
The principle of least surprise should apply whenever possible.
Thank you for re-raising this.