Skip to content

Instantly share code, notes, and snippets.

@phaedryx phaedryx/rotate.rb
Last active Dec 19, 2015

Embed
What would you like to do?
a rotator for Jeff
def rotator_factory(*values)
Enumerator.new do |y|
loop do
y.yield values.first
values = values.rotate
end
end
end
r = rotator_factory('a','b','c')
r.next # => 'a'
r.next # => 'b'
r.next # => 'c'
r.next # => 'a'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.