From: "Christopher D." Date: 2012-04-04T02:29:26+09:00 Subject: fibonacci and defining variables I was doing an example on Fibonacci sequences and this confused me a little. The problem happens because of how I define my variables. Can someone explain to me how i, p = p, i + p does not equal i = p, p = i+p Here is the correct program which returns: 1,1,2,3,5,8 def fib(max) i, p = 1, 1 while i <= max yield i i, p = p, i+p end end fib(40) { |f| puts f } Here is the incorrect problem which returns: 1,1,2,4,8 def fib(max) i, p = 1, 1 while i <= max yield i i = p p = i+p end end fib(10) { |f| puts f } -- Posted via http://www.ruby-forum.com/.