Ruby Operators Precedence
Operators Precedence
Here is the list of Ruby operators, by precedence (high to low) :
Operator(s) | Operation |
---|---|
!, ~, + | Boolean NOT, bitwise complement, unary plus |
** | Exponentiation |
- | Unary minus (define with [email protected]) |
*, /, % | Multiplication, division, modulo (remainder) |
+, - | Addition (or concatenation), subtraction |
<<, >> | Bitwise shift-left (or append), bitwise shift-right |
& | Bitwise AND |
|, ^ | Bitwise OR, bitwise XOR |
>, >=, <, <= | Ordering |
<=>, ==, ===, !=, =~, !~ | Equality, pattern matching, comparison |
&& | Boolean AND |
|| | Boolean OR |
.., ... | Range creation and Boolean flip-flops |
?, : | Conditional |
modifier-rescue | Exception-handling modifier |
=, +=, -=, etc. | Assignment |
defined? | Test variable definition and type |
not | Boolean NOT (low precedence) |
or, and | Boolean OR, Boolean AND |
modifier-if, modifier-unless, modifier-while, modifier-until | Conditional and loop modifiers |
{ } blocks | blocks |
Previous:
Ruby Variables, Constants
Next:
Ruby Arithmetic Operators
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework