O'Reilly logo

Ruby Quick Syntax Reference by Matt Clements

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 2

image

Operators

Expressions

Unlike other programming languages, in Ruby there isn’t a distinction between statements and expressions: everything is evaluated as an expression that produces a return value. The simplest expressions are:

  • literals: values such as numbers, strings, arrays, hashes, etc…
  • variable and constant references: A variable (or a constant) is referenced by citing its name. For example:
    x = 1 # assignment expressionx # variable reference expressionMY_CONST # constant reference
  • method invocations: the (return) value of a method invocation is the value of the last evaluated expression in the body of the method.

Operators

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required