David A. Black wrote: > Hi -- > > On Mon, 15 Oct 2007, SpringFlowers AutumnMoon wrote: > >> >> foo(i) >> 3 >> 4 >> 5 >> 6 >> 7 >> 8 >> 9 >> 10 >> 1 > > There's no relation or connection between the two. The def keyword > always starts a new local scope; the if keyword doesn't. There's no > reason to expect them to behave the same way as each other, as they > serve entirely different purposes. So in a way, think of a code block like a "if" statement? (no new local scope) Come to think about it, since [1,2,3,4,5].each {|a| p a} is equivalent to for a in [1,2,3,4,5] p a end so the "for" version clearly doesn't have a new scope for "a". But in the newest Ruby 1.9, they are not equivalent any more? -- Posted via http://www.ruby-forum.com/.