Skip to content

Instantly share code, notes, and snippets.

@cheald
Created November 4, 2014 23:05
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 cheald/9d84bd863c20f7570d63 to your computer and use it in GitHub Desktop.
Save cheald/9d84bd863c20f7570d63 to your computer and use it in GitHub Desktop.
obj = Object.new
class << obj
include Enumerable
def each
yield 1
end
end
a = []
cond = ->(v, i) { a << v }
obj.each_with_index.cycle(2, &cond)
a # => [1, 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment