Skip to content

Instantly share code, notes, and snippets.

@john1king
Created May 18, 2013 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save john1king/5604162 to your computer and use it in GitHub Desktop.
Save john1king/5604162 to your computer and use it in GitHub Desktop.
# http://melborne.github.io/2012/07/12/object-repeat-take-care-of-sequence/
class Object
def repeat(init=true, &blk)
x = self
Enumerator.new do |y|
y << x if init
loop { y << (x = yield x) }
end
end
end
c = '@'
60.times.map { c = c.succ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment