What is Ruby's double-colon (::) all about?
- by Meltemi
I'd probably be able to answer this for myself if "::" wasn't so hard to Google. Didn't see anything on SO so thought I'd try my luck.
What is this double-colon :: all about? I see it everywhere in Rails:
class User < ActiveRecord::Base
or…
ActionController::Routing::Routes.draw do |map|
I found a definition from this guy:
The :: is a unary operator that
allows: constants, instance methods
and class methods defined within a
class or module, to be accessed from
anywhere outside the class or module.
but that just leads to more questions. What good is scope (private, protected) if you can just use :: to expose anything?