On Wed, 14 Mar 2001, Leo Razoumov wrote:

> If I understand you correctly, your proposed new block {{..}} shadows
> _ALL_ local variables inside it while conventional Ruby's block {...}
> shadows _NONE_. What I really need is the construct when _SOME_ locals
> are shadowed while the rest are not.

Using the proposed syntax changes, this can be done by:

  a = 1
  b = 2
  c = 3

  (1..3).each do |i, a, c|
    a = a * i
    b = b * i
    c = c * i
  end

  p [a, b, c]         -> [1, 12, 3]

The variables in the parameter list are shadowed, so you can list the
ones you want to be shadowed. Since "each" only passes one value, only
'i' will be updated on each loop through.

Yes, this is a bit of a kludge, as noted in the proposal... but then
again, so is the concept of shadowing some variables and not others.

At least this is a clean kludge.

-- 
  spwhite / chariot.net.au