Both .
and ::
can be used to call class methods, but, in my experience, .
is by far the most commonly used of the two. So I am accustomed to using that form in documentation and RSpec describe/context/expect strings.
However, the Ruby API documentation uses ::
(e.g. at https://rubyapi.org/3.1/o/string). Is that intended to mean that that form is preferred for the cases I described?
Note: This is not a duplicate of Is there a difference between :: and . when calling class methods in Ruby?. That question refers to the use of the two alternate notations in Ruby source code, whereas this question refers to documentation and other textual descriptions (e.g. in rspec strings). There may be reasons to make different choices in code vs. documentation, for example, that using .
in code more clearly indicates a message call vs. a constant access, whereas in documentation ::
might be preferred to more dramatically distinguish class methods from instance methods.