Address Ameba issue

This commit is contained in:
Michael Miller 2021-08-17 15:02:34 -06:00
parent 94d5c96e7d
commit 38ea2e7f96
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD

View file

@ -18,10 +18,9 @@ module Spectator
# Retrieves the next `Node`. # Retrieves the next `Node`.
# If there are none left, then `Iterator::Stop` is returned. # If there are none left, then `Iterator::Stop` is returned.
def next def next
# Keep going until either: # Nothing left to iterate.
# a. a node is found. return stop if @stack.empty?
# b. the stack is empty.
until @stack.empty?
# Retrieve the next node. # Retrieve the next node.
node = @stack.pop node = @stack.pop
@ -32,11 +31,7 @@ module Spectator
end end
# Return the current node. # Return the current node.
return node node
end
# Nothing left to iterate.
stop
end end
# Restart the iterator at the beginning. # Restart the iterator at the beginning.