Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def make_fibonacci
- current = 0
- _next = 1
- lambda do
- fibonacci = current
- current, _next = _next, current + _next
- return fibonacci
- end
- end
- iterator = make_fibonacci
- 10.times do
- num = iterator.call
- puts num
- end
Add Comment
Please, Sign In to add comment