Skip to content

Instantly share code, notes, and snippets.

@yrgoldteeth
Forked from banister/tailing ruby with let.rb
Created February 23, 2011 15:57
Show Gist options
  • Save yrgoldteeth/840597 to your computer and use it in GitHub Desktop.
Save yrgoldteeth/840597 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