← Graph

Scope Resolution Operator

concept 2 connections

Ruby's `::` operator, properly called the scope (or constant) resolution operator, used primarily to reference constants, classes and modules. It can also be used to call methods (`User::new.hello`), which works but is discouraged by RuboCop for regular method calls. Not fully interchangeable with `.`: `::` also performs constant lookup, so `Workplace::User` resolves a constant inside Workplace while `Workplace.User` is a method call.

category
pattern
about
Scope Resolution Operator concept
Covers calling methods via :: and why RuboCop discourages it.
about
Scope Resolution Operator concept
Takeaway concerns using :: vs . for invocation.

Provenance

Read by
3 extractions