The Ruby Way, Second Edition: Solutions and Techniques in Ruby Programming (2nd Edition)

 

   

Ruby Way

By Hal Fulton

Slots : 1.0

Table of Contents
 

Dot notation in Ruby is used strictly for method dispatch. The left side is the object or variable, and the right side is the method name. The result is always an object, so you can chain method calls as in Python.

The :: scope operator is needed to access nested modules, classes, and their constants. It can also optionally be used to access a class method.

Methods can also be called without dot notation, in which case Ruby will implicitly use self as the receiver. However, the parser will influence operators implemented as methods and used without dot notation.

print 3 + 4 * 5 # 23 print 3.+(4).*(5) # 35


   
 

Категории