lib/code/node/if.rb in code-ruby-1.0.0 vs lib/code/node/if.rb in code-ruby-1.1.0

- old
+ new

@@ -33,27 +33,32 @@ @elses = parsed.delete(:elses).presence || [] @elses.map! { |elses| Node::If::Else.new(elses) } end def evaluate(**args) - if @first_operator == IF_KEYWORD && - @first_statement.evaluate(**args).truthy? + if ( + @first_operator == IF_KEYWORD && + @first_statement.evaluate(**args).truthy? + ) || + ( + @first_operator == UNLESS_KEYWORD && + @first_statement.evaluate(**args).falsy? + ) @first_body.evaluate(**args) - elsif @first_operator == UNLESS_KEYWORD && - @first_statement.evaluate(**args).falsy? - @first_body.evaluate(**args) else (@elses || []).each do |elses| - if elses.operator == ELSIF_KEYWORD && - elses.statement.evaluate(**args).truthy? - return elses.body.evaluate(**args) - elsif elses.operator == IF_KEYWORD && - elses.statement.evaluate(**args).truthy? - return elses.body.evaluate(**args) - elsif elses.operator == UNLESS_KEYWORD && - elses.statement.evaluate(**args).falsy? - return elses.body.evaluate(**args) - elsif elses.operator == ELSE_KEYWORD + if ( + elses.operator == ELSIF_KEYWORD && + elses.statement.evaluate(**args).truthy? + ) || + ( + elses.operator == IF_KEYWORD && + elses.statement.evaluate(**args).truthy? + ) || + ( + elses.operator == UNLESS_KEYWORD && + elses.statement.evaluate(**args).falsy? + ) || (elses.operator == ELSE_KEYWORD) return elses.body.evaluate(**args) end end ::Code::Object::Nothing.new