Difference between "Class#message" and "Class.message" notation

This is a very basic ruby question. What is the difference between ClassName#message and ClassName.message?

I am reading a basic Ruby guide and I see both references used quite a lot. It seems that mainly in the code ClassName.message is used but in the documentation ClassName#message is used.

Is the # simply documentation convention? Will only the . work for message passing in actual code? Or is there something that I am just missing?

Does the meaning differ in Rails at all?


In code you use object.method. In documentation however, Class#method denotes an instance method (e.g. String#upcase), whereas Class.method or Class::method denotes a class/module method (e.g. Math.log10).

The # is used in the documentations to point out the difference between class methods and instance methods.

In the code, you'll be using . in all the cases.

'#' is rails convention. In rails className#Message will map to Message action of your className controller.

   match "profile" => "users#show"

This will map root_path/profile => Show method(or action) of UserController.

Need Your Help

A* Algorithm and use of F and G heuristics


I've got my A* algorithm working to a degree. It will follow the player around in a space, but it will not go around an object which involves moving farther away from the target in order to get ar...

Can I add a relative path to directory to add a repository to Trac?


I am able to add a absolute path directory for the trac repository. When I give a relative path, It is not accepting it. Is there any config which I am missing for this in Trac?