From: Sebastian Hungerecker Date: 2008-09-27T18:14:18+09:00 Subject: Re: Does array's each-block destroies outer objects ? w wg wrote: > After execute the block , it looks like that ruby destroied the former > 'x' object, the 'x' object has object_id 4 now, which is same as > a[4].object_id. Yes, if you do {|foo|...} and you have a local variable foo outside the block, then the outer foo will be replaced by the value that is yielded to the block. This is a property of blocks in 1.8, not of each in particular. This behaviour will no longer be present in 1.9. > If so , does it mean that I must choose another variable name in > array's each block to keep the 'x' object alive ? Yes. HTH, Sebastian -- NP: Die Apokalyptischen Reiter - Ein Lichtlein Jabber: sepp2k@jabber.org ICQ: 205544826