title: Operator precedence in C++
body: <p>For the following function</p>
  
  <blockquote>
  <pre><code>int search(int n) {
      return arr[n] == n ? n : arr[n] = search(arr[n]);
  }
  </code></pre>
  </blockquote>
  
  <p>Not very sure exactly what it's supposed to do. According to what I understand about operator precedence, my guess is that above is equivalent to </p>
  
  <pre class="lang-cpp prettyprint-override"><code>int search(int n) {
      if (arr[n] == n) {
          return n;
      } else {
          return arr[n] = search(arr[n]);
      }
  }
  </code></pre>
  
  <p>but then it doesn't really make sense to me that the function is returning an assignment? Or am I interpreting it wrong entirely?</p>