HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/src/ruby-3.0.2/doc/syntax/precedence.rdoc
= Precedence

From highest to lowest, this is the precedence table for ruby.  High precedence
operations happen before low precedence operations.

  !, ~, unary +

  **

  unary -

  *, /, %

  +, -

  <<, >>

  &

  |, ^

  >, >=, <, <=

  <=>, ==, ===, !=, =~, !~

  &&

  ||

  .., ...

  ?, :

  modifier-rescue

  =, +=, -=, etc.

  defined?

  not

  or, and

  modifier-if, modifier-unless, modifier-while, modifier-until

  { } blocks

Unary <code>+</code> and unary <code>-</code> are for <code>+1</code>,
<code>-1</code> or <code>-(a + b)</code>.

Modifier-if, modifier-unless, etc. are for the modifier versions of those
keywords.  For example, this is a modifier-unless statement:

  a += 1 unless a.zero?

Note that <code>(a if b rescue c)</code> is parsed as <code>((a if b) rescue
c)</code> due to reasons not related to precedence. See {modifier
statements}[control_expressions_rdoc.html#label-Modifier+Statements].

<code>{ ... }</code> blocks have priority below all listed operations, but
<code>do ... end</code> blocks have lower priority.

All other words in the precedence table above are keywords.