Chapter 3 Flashcards
Expression?
Combination of numbers, operators and variables that, when understood by the computer, result in an answer of some form.
Number Comparison Operators in Ruby?
x > y Greater than
x < y Less than
x == y Equal to
x >= y Greater than or equal to
x <= y Less than or equal to
x <=> y Comparison; returns 0 if x and y are equal, 1 if x is higher, and −1 if y is higher
x != y Not equal to
Basic loop
.times 5.times
Iterator
Progresses through a list of items one by one. ..or different multiples:
.each
- upto(5)
- downto(5)
- step(50, 5)
- upto(5) { |number| puts number }
String Literal
When a string is embedded directly into code, using quotation marks.
Interpolation
Embedding expressions and even logic into strings
x = 10 y = 20
puts “#{x} + #{y} = #{x + y}”
String Methods

Regular Expression
is a string that describes a pattern for matching elements in other strings.
Operator
Something that’s used in an expression to manipulate objects such as+(plus), - (minus), * (multiply), and / (divide). You can also use operators to do comparisons, such as with <, >, and &&.
Arrays
A collection of objects or values with a defined, regular order.
x = [1, 2, 3, 4]
Array Index
position within the array.
Array Literal
Square brackets are used to denote an array literal.
Array Element Reference
To access a particular element, an array (or a variable containing an array) is followed by the index contained within square brackets.
puts x[2]
Array <<
is the operator for pushing an item onto the end of an array. It’s equivalent to the push method.
Array Push
equivalent to <<
x.push(“word”)