Skip to content

Instantly share code, notes, and snippets.

@gabteles
Created June 23, 2015 20:59
Show Gist options
  • Save gabteles/def49642a6e8b4e47e1b to your computer and use it in GitHub Desktop.
Save gabteles/def49642a6e8b4e47e1b to your computer and use it in GitHub Desktop.
Implements "for" like c, cpp, java, etc
module Kernel
def cfor(init, condition, inc)
while condition.()
yield
inc.()
end
end
end
if ($0 == __FILE__)
cfor(i = 1, ->{i < 20}, ->{i += 1}) do
puts i
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment