<分区>
::
在 Ruby 中是什么意思?例如。 Foo::Bar
.
<分区>
::
在 Ruby 中是什么意思?例如。 Foo::Bar
.
最佳答案
When a receiver is explicitly specified in a method invocation, it may be separated from the method name using either a period (
.
) or two colons (::
). The only difference between these two forms occurs if the method name starts with an uppercase letter. In this case, Ruby will assume that areceiver::Thing
method call is actually an attempt to access a constant calledThing
in the receiver unless the method invocation has a parameter list between parentheses.
关于ruby -::(双冒号)在 Ruby 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2276905/