To Documents

Ruby/JavaScript Operator Dictionary

Here is a Ruby/JavaScript dictionary of some Ruby operators.

Ruby JavaScript Meaning Ruby
Method?
Ruby Return
Type
Ruby
Precedence
a[i] a[i] ith element of array a Yes Type of array
element
1
n.to_s n.toString() dot operator No   1
a ** n Math.
pow(a, n)
a raised to the n power Yes Float 2
!expr !expr if expr is true, return false;
if false, return true
Yes Boolean 3
+5 +5 positive 5 (not usually used) Yes Numeric 3
-5 -5 negation of 5 Yes Numeric 3
x * y x * y x multiplied by y Yes Numeric 4
x / y x / y x divided by y Yes Numeric 4
x % y x % y x mod y (remainder from
integer division)
Yes Numeric 4
x + y x + y sum of x and y Yes Numeric 5
s + t s + t concatenate s and t Yes String 5
x - y x - y difference of x minus y Yes Numeric 5
x < y x < y x is less than y Yes Boolean 6
x > y x > y x is greater than y Yes Boolean 6
x <= y x <= y x is less than or equal to y Yes Boolean 6
x >= y x >= y x is greater than or equal to y Yes Boolean 6
x == y x == y x is equal to y Yes Boolean 7
x != y x != y x is not equal to y Yes Boolean 7
expr1 && expr2 expr1 && expr2 logical and No Boolean 8
expr1 || expr2 expr1 || expr2 logical or No Boolean 9
y = x y = x; assign value of x to y No Type of x 10