Ruby: Use the return of the conditional for variable assignment and comparison : <p>I have a method and in order to check whether it is being passed a block, I do the following:</p>

<pre><code>if block_given?
    res = yield(array[i], array[i+1])
  else
    res = array[i] - array[i+1]
  end
</code></pre>

<p>However RuboCop is giving me a warning which I don't really understand in the <code>if block_given?</code> line: </p>

<blockquote>
  <p>Use the return of the conditional for variable assignment and comparison</p>
</blockquote>

<p>Is there any other more rubyist way of doing this?</p>

<p>Thanks</p>
