Ruby: Foo.bar vs Foo#bar

Foo.Bar means a class method, meaning a static method (in C# or Java).

Foo#Bar means an instance method, meaning it’s a method called from an initialized object. 

One of the rules of thumb of responsible power usage is to wield the minimal power you need to get what you need done, done.

See ruby-lang documentation, where it references instance methods using “#” sign. 

And for static methods, it uses “::” to denote class methods.

Note: Hash (#) and double colon (::) as denotation characters for instance and class methods are also supported by ri (the command-line viewer of source code documentation) which is distributed along with Ruby.

Leave a Reply

Your email address will not be published. Required fields are marked *