Skip to content

Instantly share code, notes, and snippets.

@ir-norn
Last active September 25, 2015 03:25
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 ir-norn/4e15a3581f95774873fd to your computer and use it in GitHub Desktop.
Save ir-norn/4e15a3581f95774873fd to your computer and use it in GitHub Desktop.
task
class Task
def initialize
@func =->{yield self}
end
def update
@func.call
end
end
task = []
task << Task.new { p 2 }
task << Task.new { p 4 }
task << Task.new {|o|
p o
@n ||= 0
exit if (@n+=1) > 10
}
task.map &:update until nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment