I’m new to Ruby and throughly enjoying learning the language. I’m
currently working my way through the Pickaxe book, but have a couple
of questions I hope someone can help me out with.
As I understand it the double-colon ( :: ) can be used when calling
class methods or class constants, but could correctly be replaced by a
single dot ( . ) if preferred:
I was wondering if someone more experience could tell me which method
is used by the majority of Rubyists and whether it is thought of as
“best practice” to use the double colon?
I suspect this is probably down to personal preference. I personally
prefer the double-colon but I would like to get into good habits now
whilst I’m learning the language. The Pickaxe book doesn’t use ::
except when referring to modules (not sure if that is the correct
class TestRoman < Test::Unit::TestCase
Could someone explain whether this is convention or if there is
another reason for this?