 <p>The short answer is the operator needs to be at the end of the line in order to tell Ruby to continue reading the next line as part of the statement, so this would work:</p> <pre><code>if ( (aa != nil &amp;&amp; self.prop1 == aa.decrypt) || (bb != nil &amp;&amp; self.prop2 == bb.decrypt) ) &amp;&amp; (self.id.nil? || self.id != id) return true end </code></pre> <p>That being said, you can probably reduce the logic by throwing exceptions based on input values, and removing some redundant checks (I'm making some jumps here about what your variables will look like, but you get the idea.)</p> <pre><code>raise 'aa must support decrypt' unless aa.respond_to? :decrypt raise 'bb must support decrypt' unless bb.respond_to? :decrypt if prop1 == aa.decrypt || prop2 == bb.decrypt if self.id != id return true end end </code></pre>