← Graph

Prefer . over :: for method calls

takeaway 2 connections

Convention, codified by RuboCop: use `::` only to reference constants, classes, modules, and constructors like `Nokogiri::HTML()`; use `.` for all regular method invocation. Although `User::new.hello` works, mixing scope resolution and method dispatch creates confusion (e.g. `Workplace::User` resolves a constant while `Workplace.User` is a method call).

type
recommendation
takeaway Prefer . over :: for method calls
about
Takeaway concerns using :: vs . for invocation.
takeaway Prefer . over :: for method calls
from_talk
Discussed alongside the RuboCop rule.

Provenance