HEX
Server: Apache
System: Windows NT MAGNETO-ARM 10.0 build 22000 (Windows 10) AMD64
User: Michel (0)
PHP: 7.4.7
Disabled: NONE
Upload Files
File: C:/Ruby27-x64/share/doc/ruby/html/syntax/precedence_rdoc.html
<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">

<title>precedence - RDoc Documentation</title>

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
</script>

<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<link href="../css/fonts.css" rel="stylesheet">
<link href="../css/rdoc.css" rel="stylesheet">




<body id="top" role="document" class="file">
<nav role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2>
    <a href="../index.html" rel="home">Home</a>
  </h2>

  <div id="table-of-contents-navigation">
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  

  <div id="project-metadata">
    <div id="fileindex-section" class="nav-section">
  <h3>Pages</h3>

  <ul class="link-list">
  
    <li><a href="../CONTRIBUTING_md.html">CONTRIBUTING</a>
  
    <li><a href="../COPYING.html">COPYING</a>
  
    <li><a href="../COPYING_ja.html">COPYING.ja</a>
  
    <li><a href="../LEGAL.html">LEGAL</a>
  
    <li><a href="../NEWS.html">NEWS</a>
  
    <li><a href="../NEWS-1_8_7.html">NEWS-1.8.7</a>
  
    <li><a href="../NEWS-1_9_1.html">NEWS-1.9.1</a>
  
    <li><a href="../NEWS-1_9_2.html">NEWS-1.9.2</a>
  
    <li><a href="../NEWS-1_9_3.html">NEWS-1.9.3</a>
  
    <li><a href="../NEWS-2_0_0.html">NEWS-2.0.0</a>
  
    <li><a href="../NEWS-2_1_0.html">NEWS-2.1.0</a>
  
    <li><a href="../NEWS-2_2_0.html">NEWS-2.2.0</a>
  
    <li><a href="../NEWS-2_3_0.html">NEWS-2.3.0</a>
  
    <li><a href="../NEWS-2_4_0.html">NEWS-2.4.0</a>
  
    <li><a href="../NEWS-2_5_0.html">NEWS-2.5.0</a>
  
    <li><a href="../NEWS-2_6_0.html">NEWS-2.6.0</a>
  
    <li><a href="../README_ja_md.html">README.ja</a>
  
    <li><a href="../README_md.html">README</a>
  
    <li><a href="../bug_triaging_rdoc.html">bug_triaging</a>
  
    <li><a href="../contributing_rdoc.html">contributing</a>
  
    <li><a href="../contributors_rdoc.html">contributors</a>
  
    <li><a href="../dtrace_probes_rdoc.html">dtrace_probes</a>
  
    <li><a href="../extension_ja_rdoc.html">extension.ja</a>
  
    <li><a href="../extension_rdoc.html">extension</a>
  
    <li><a href="../globals_rdoc.html">globals</a>
  
    <li><a href="../keywords_rdoc.html">keywords</a>
  
    <li><a href="../lib/racc/pre-setup.html">pre-setup</a>
  
    <li><a href="../lib/racc/rdoc/grammar_en_rdoc.html">grammar.en</a>
  
    <li><a href="../maintainers_rdoc.html">maintainers</a>
  
    <li><a href="../marshal_rdoc.html">marshal</a>
  
    <li><a href="../regexp_rdoc.html">regexp</a>
  
    <li><a href="../security_rdoc.html">security</a>
  
    <li><a href="../signals_rdoc.html">signals</a>
  
    <li><a href="../standard_library_rdoc.html">standard_library</a>
  
    <li><a href="../syntax_rdoc.html">syntax</a>
  
    <li><a href="../syntax/assignment_rdoc.html">assignment</a>
  
    <li><a href="../syntax/calling_methods_rdoc.html">calling_methods</a>
  
    <li><a href="../syntax/comments_rdoc.html">comments</a>
  
    <li><a href="../syntax/control_expressions_rdoc.html">control_expressions</a>
  
    <li><a href="../syntax/exceptions_rdoc.html">exceptions</a>
  
    <li><a href="../syntax/literals_rdoc.html">literals</a>
  
    <li><a href="../syntax/methods_rdoc.html">methods</a>
  
    <li><a href="../syntax/miscellaneous_rdoc.html">miscellaneous</a>
  
    <li><a href="../syntax/modules_and_classes_rdoc.html">modules_and_classes</a>
  
    <li><a href="../syntax/precedence_rdoc.html">precedence</a>
  
    <li><a href="../syntax/refinements_rdoc.html">refinements</a>
  
    <li><a href="../win32/README_win32.html">README.win32</a>
  
  </ul>
</div>

  </div>
</nav>

<main role="main" aria-label="Page syntax/precedence.rdoc">

<h1 id="label-Precedence">Precedence<span><a href="#label-Precedence">&para;</a> <a href="#top">&uarr;</a></span></h1>

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

<pre>!, ~, unary +

**

unary -

*, /, %

+, -

&lt;&lt;, &gt;&gt;

&amp;

|, ^

&gt;, &gt;=, &lt;, &lt;=

&lt;=&gt;, ==, ===, !=, =~, !~

&amp;&amp;

||

.., ...

?, :

modifier-rescue

=, +=, -=, etc.

defined?

not

or, and

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

{ } blocks</pre>

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

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

<pre class="ruby"><span class="ruby-identifier">a</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">zero?</span>
</pre>

<p>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 <a href="control_expressions_rdoc.html#label-Modifier+Statements">modifier statements</a>.</p>

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

<p>All other words in the precedence table above are keywords.</p>

</main>



<footer id="validator-badges" role="contentinfo">
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
  <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1.
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>