-
-
Save dstarh/2da1a324dad8149ab201 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def while_with_index(proc, &block) | |
index = 0 | |
loop do | |
break unless proc.call | |
yield index | |
index += 1 | |
end | |
end | |
a = "woot" | |
while_with_index(Proc.new {a != "foobar" }) do |index| | |
puts "index = #{index}" | |
a = "foobar" if index == 10 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment