| class | instance | |
| constants | Y | N |
| class methods | Y | N |
| instance methods | N | Y |
| . | :: | |
| constants | N | Y |
| class methods | Y | Y |
| instance methods | Y | Y |
The double colon notation is also known as the scope resolution operator. It looks to me like it works more with constants (given that class names and module names are themselves constants), while the dot notation is more in favor of methods, whether class methods or instance methods. Until otherwise told, I'm gonna keep my life simpler and train myself this way.
Also, hats off to these two posts:
http://stackoverflow.com/questions/2276905/what-does-double-colon-mean-in-ruby
http://stackoverflow.com/questions/18061941/dot-operator-vs-scope-resolution-operator-with-modules-in-ruby
Also, hats off to these two posts:
http://stackoverflow.com/questions/2276905/what-does-double-colon-mean-in-ruby
http://stackoverflow.com/questions/18061941/dot-operator-vs-scope-resolution-operator-with-modules-in-ruby
没有评论:
发表评论