What is Ruby's double-colon (::) all about?
Posted
by Meltemi
on Stack Overflow
See other posts from Stack Overflow
or by Meltemi
Published on 2010-06-09T20:03:36Z
Indexed on
2010/06/09
20:22 UTC
Read the original article
Hit count: 252
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?
© Stack Overflow or respective owner