Skip to content

Instantly share code, notes, and snippets.

@Pserg
Created January 29, 2018 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pserg/0d961b4c306705559595d3582065ec8b to your computer and use it in GitHub Desktop.
Save Pserg/0d961b4c306705559595d3582065ec8b to your computer and use it in GitHub Desktop.
Ruby Operator Precedence

from http://www.ruby-doc.org/docs/ProgrammingRuby/language.html#table_18.4

Table 18.4 : Ruby operators (high to low precedence)
Method Operator Description
Y [ ] [ ]= Element reference, element set
Y ** Exponentiation
Y ! ~ + - Not, complement, unary plus and minus (method names for the last two are +@ and -@)
Y * / % Multiply, divide, and modulo
Y + - Plus and minus
Y >> << Right and left shift
Y & Bitwise `and'
Y ^ | Bitwise exclusive `or' and regular `or'
Y <= < > >= Comparison operators
Y <=> == === != =~ !~ Equality and pattern match operators (!= and !~ may not be defined as methods)
&& Logical `and'
|| Logical `or'
.. ... Range (inclusive and exclusive)
? : Ternary if-then-else
= %= { /= -= += |= &= >>= <<= *= &&= ||= **= Assignment
defined? Check if symbol defined
not Logical negation
or and Logical composition
if unless while until Expression modifiers
begin/end Block expression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment