Name | Description | Syntax | Examples |
---|---|---|---|
Integer literal | A whole number | 3 -552 |
|
Float literal | A decimal number | 42.23 -0.133742 |
|
Addition Subtraction Multiplication |
Basic math | a + b a - b a * b |
5.2 + 6.34 # => 11.54 2.59 - 4.89 # => -2.3 5 * 3.7 # => 18.5 |
Division | Mind the difference between integer and float division! | a / b | # integer division: 6 / 4 # => 1 # float division: 6 / 4.0 # => 1.5 |
Modulo | Return the remainder of a division | a % b | 13 % 6 # => 1 |
String literal | A string of characters, text | "this is a string" |
|
String interpolation | Text with Ruby code embedded within | "another string with #{interpolation}!" |