Changes

Jump to: navigation, search

Understanding Ruby Logical Operators

20 bytes added, 19:17, 19 November 2007
no edit summary
''If var is less than 25 AND var2 is greater than 45 then return true''
Here the logical operator is the "AND" part of the sentence. If we were to express this in Ruby we would use the comparison operators we covered earlier together with the ''and'' or ''&&'' logical operatoroperators:
<pre>
''If var1 is less than 25 OR var2 is greater than 45 return true.''
Then we would replace the "OR" with the Ruby equivalent ''or'', or '||':
<pre>

Navigation menu