3 ms·
> It's worth noting that two of such ways will, perhaps unintuitively, ignore the `private` keyword. No, this explanation is wrong, because there isn't actuall
by dragonwriter 2y ago
> It's worth noting that two of such ways will, perhaps unintuitively, ignore the `private` keyword.
No, this explanation is wrong, because there isn't actually a `private` keyword, only the Module#private method [0] which, when called with no arguments, changes the visibility of future methods defined in the target module.
Those examples call the `Module#private` method with no arguments in one context changing the visibility of future methods defined in that context, and then use an explicit prefix to define methods in a different context.
When you don't forget that `private` is a private instance method on Module and not a keyword, the behavior is much simpler to understand.
[0] https://ruby-doc.org/3.4.1/Module.html#method-i-private https://ruby-doc.org/3.4.1/Module.html#method-i-private
- lcnPylGDnU4H9OF 2y agoThanks for the correction! It can be hard to appreciate how true “everything is an object” is.
- dragonwriter 2y agoThat and how, between block arguments and optional parens on method invocation, Ruby allows (and the core exploits this) defining lots of constructs that look like keyword-based syntax as methods.