From: Phillip Gawlowski Date: 2011-05-28T09:37:01+09:00 Subject: Re: Variable scopes with code blocks. On Sat, May 28, 2011 at 12:22 AM, Patrick Lynch wrote: > Hello! > > That said, I'm aware of the limits you have with local variable being > incapable of accessing variables defined inside of a code block, but is > there any exception to this rule? What you can do is declaring the variable before the block, and access it within the block. Like so: >> a = [] # Let's store data in an array >> (1..3).each do |i| ?> a << i # We append the index i to the array >> end => 1..3 >> puts a # Now contains [1, 2, 3]. -- Phillip Gawlowski A method of solution is perfect if we can forsee from the start, and even prove, that following that method we shall attain our aim.                -- Leibnitz