Simon Kr?ger wrote:
> 
>>> This very useful little method is a nice thing to have in your
>>> bag-o-tricks.
>>
>>
>> Nice. you could even call it #then:
>>
>> class Object
>>   def then
>>     yield(self)
>>     self
>>   end
>> end
>>
>> #Then you could do these types of things:
>> a = (0..10).to_a
>> i = 3
>> p a[i.then{i+=1}]
>> p i
>>
>> [..snip..]
> 
> 
> But be carefull:
> 
> i = 3
> p i.then{i+=1}
> p i
> 
> i = [3]
> p i.then{i << 4}
> p i
> 
> 
> output:
> 3
> 4
> [3, 4]
> [3, 4]
> 
> 
> (perhaps this was obvious to all, except me)
> 
> cheers
> 
> Simon

Good point. You really have to be especially clear about whether you are
 modifying a variable binding or an object.

i = [3]
p i.then{i+=[4]}   # ==> [3]
p i                # ==> [3, 4]

-- 
      vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407