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

后端 未结 10 1998
南笙
南笙 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 11:01

    It is all about preventing definitions from clashing with other code linked in to your project. It means you can keep things separate.

    For example you can have one method called "run" in your code and you will still be able to call your method rather than the "run" method that has been defined in some other library that you have linked in.

提交回复
热议问题