::A::B# like /A/B# is an absolute path to the constant.A::B# like ./A/B# is a path relative to the current tree level.
1234567891011121314151617
COUNT=0# constant defined on main Object classmoduleFooCOUNT=0::COUNT=1# set global COUNT to 1COUNT=2# set local COUNT to 2end# 因爲 constant 通常是不能變動的,但在 ruby 只會做緊告# (irb):4: warning: already initialized constant COUNT# (irb):1: warning: previous definition of COUNT was here# (irb):5: warning: already initialized constant Foo::COUNT# (irb):3: warning: previous definition of COUNT was hereputsCOUNT# this is the global constant# => 1putsFoo::COUNT# this is the local "Foo" constant# => 2