An example of redo statement in Ruby, redo makes an iteration step repeat itself again (http://www.rubyrailways.com/rubys-most-underused-keyword/).
- # no recursion (1.8 has no tail call optimization)
- def fib(i)
- acc = lambda do |i, n, result|
- if i == -1
- i, n, result = i - 1, n + result, n
- end.call(i, 1, 0)
You need to login to post a comment.