Skip to content

Instantly share code, notes, and snippets.

@skade
Created July 3, 2016 20:09
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 skade/c3bc23db676debb3cc72cbb224f34084 to your computer and use it in GitHub Desktop.
Save skade/c3bc23db676debb3cc72cbb224f34084 to your computer and use it in GitHub Desktop.
def f0r(init, condition, step, &block)
var, step = *step
while condition[var]
eval "i = #{var}", block.binding
yield
var = step[var]
end
end
class Fixnum
alias :smaller :<
alias :add :+
def <(other)
->(i){ i.smaller(other) }
end
def +(other)
[self, ->(i){ i.add(other) }]
end
end
f0r i = 1, i < 5, i += 1 do
puts "in block #{i}"
end
@Mic92
Copy link

Mic92 commented Jul 21, 2016

Don't try this at home!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment