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

后端 未结 10 1996
南笙
南笙 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:38

    What good is scope (private, protected) if you can just use :: to expose anything?

    In Ruby, everything is exposed and everything can be modified from anywhere else.

    If you're worried about the fact that classes can be changed from outside the "class definition", then Ruby probably isn't for you.

    On the other hand, if you're frustrated by Java's classes being locked down, then Ruby is probably what you're looking for.

提交回复
热议问题