From: "Mauricio Fernández" Date: 2002-10-08T17:43:04+09:00 Subject: Re: Specifying local and external block parameters (that old chestnut) On Mon, Oct 07, 2002 at 12:01:41AM +0900, ts wrote: > >>>>> "M" == MikkelFJ writes: > > M> := assigns to local block scope, > > := assign to a variable which is always local to the block, even if a > variable with the same name exist in an outer block. For example > > b = 12 > 1.times { b := 2 } > > `b := 2' will create a new block variable which shadow the previous > variable `b' matz said previously that in (0...10).each { |x| ... } the values would be assigned to x with ':=', that is, x = ... inside the block would use the local. Put otherwise, this is the same as the "make them all local" solution w.r.t. block parameters! > M> = assigns to outside the local block scope. > > = has the same meaning than actually, if a previous variable exist ruby > use this variable otherwise it create a variable local to the block > Isn't this much stranger than what we have now? i = 0 x = 'some value' (0...10).each do |i| x := 'surprise!' if i == 2 x = i # uses local after the := is run end x => 1 Having 'x = ...' meaning completely different things depending on the "execution context" makes me feel unsecure. > > M> What happens with nested scopes. > > same > -- Mauricio Julio Fernandez Pradier