Skip to content

Instantly share code, notes, and snippets.

@duarten
Forked from banister/tailing ruby with let.rb
Created June 21, 2011 19:35
Show Gist options
  • Select an option

  • Save duarten/1038680 to your computer and use it in GitHub Desktop.

Select an option

Save duarten/1038680 to your computer and use it in GitHub Desktop.
# I want this method in ruby-core
def let
yield
end
def fib(i)
let do |n = 1, result = 0|
if i == -1
result
else
i, n, result = i - 1, n + result, n
redo
end
end
end
puts fib(10) #=> 89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment