From: Morton Goldberg Date: 2007-06-21T16:12:47+09:00 Subject: Re: Two Problems From a Newbie On Jun 21, 2007, at 1:50 AM, danielj wrote: > def mtdarry > > 10.times do |num| > > square = num * num > > return num, square if num > 5 > > end > > end > > num, square = mtdarry > > puts num > puts square > > I can't figure out why this outputs they way it does? I know it is > simple but I just don't get it. The above is equivalent to: def foo 10.times do |n| a = [n, n * n] return a if n > 5 end end num, square = foo puts num, square But consider the following: def foo 10.times { |n| return [n, n * n] if n > 5 } end num, square = foo puts num, square This is better because it only computes the array for n = 6, not for 0..6. > Secondly, I have just started using the SCiTE editor instead of > metapad and it is great! However, when I try to get a string it won't > let me type into the window that pops up. Can't help you here. Don't know anything about the SCiTE editor. Regards, Morton