Ruby: Use the return of the conditional for variable assignment and comparison
What the warning is telling you to do is: res = if block_given? yield(array[i], array[i+1]) else array[i] – array[i+1] end That is, having a single assignment instead of two (or even more).