lib/code/node/while.rb in code-ruby-0.5.6 vs lib/code/node/while.rb in code-ruby-0.6.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
class Code
class Node
class While < Node
WHILE_KEYWORD = "while"
UNTIL_KEYWORD = "until"
@@ -13,22 +15,22 @@
def evaluate(**args)
if @operator == WHILE_KEYWORD
last = ::Code::Object::Nothing.new
- while @statement.evaluate(**args).truthy?
- last = @body.evaluate(**args)
- end
+ last = @body.evaluate(**args) while @statement.evaluate(
+ **args
+ ).truthy?
last
elsif @operator == UNTIL_KEYWORD
last = ::Code::Object::Nothing.new
last = @body.evaluate(**args) while @statement.evaluate(**args).falsy?
last
else
- raise NotImplementedError.new(@operator)
+ raise NotImplementedError, @operator
end
end
end
end
end