From: Ilmari Heikkinen Date: 2005-01-21T03:01:02+09:00 Subject: Re: Confused about variable "declarations" On 20.1.2005, at 19:31, Robert Klemme wrote: > > "Mark Hubbart" schrieb im Newsbeitrag > news:de63abca050120090877cc9971@mail.gmail.com... >> On Thu, 20 Jan 2005 21:01:01 +0900, Graham Nicholls >> wrote: >>> No worries, and thanks, but I think that the problem was that offset > is >>> being set inside an iterator (they still confuse me - any pointers to > a >>> good explanation would be nice!), which means that it is out of scope >>> outside the iterator. >> >> A short explanation: Blocks have a sort of "leaky scope", where >> variables from outside the scope can leak in and out, but those that >> are from the inside don't leak out. for example: > > While I completely agree with your explanation the word "leaky" > strikes me > as odd as it seems to suggest uncommon or defective behavior: it's > very > common in programming languages, that variables are visible in nested > scopes but not surrounding scopes: > This may be the leaky case: x = 10 arr = (x..100).map{|x| x*2} x #=> 100 :) -- Ilmari Heikkinen