What is Ruby's double-colon `::`?

后端 未结 10 2126
南笙
南笙 2020-11-22 10:09

What is this double-colon ::? E.g. Foo::Bar.

I found a definition:

The :: is a unary operator that all

10条回答
  •  日久生厌
    2020-11-22 10:43

    module Amimal
          module Herbivorous
                EATER="plants" 
          end
    end
    
    Amimal::Herbivorous::EATER => "plants"
    

    :: Is used to create a scope . In order to access Constant EATER from 2 modules we need to scope the modules to reach up to the constant

提交回复
热议问题