From: SonOfLilit Date: 2007-07-16T21:26:09+09:00 Subject: Re: clean nice way (hash) On 7/16/07, Stefan Rusterholz wrote: > SonOfLilit wrote: > >> > > a.each {|key,value| a[key] = {'name' => value}} > >> > > >> > Are you allowed to do this? > >> > >> Why not? Seem to work here. > >> > > > > I was taught not to modify a structure I'm #each ing on... > > > > Does this not apply when you only modify substructures of it? > > > > > > Aur > > I think that only applies for insert/delete. As e.g. with an array it > may happen that elements are left out if you delete them wile iterating, > or that you iterate over a newly create value (which you might not want > to) > > Regards > Stefan > > -- > Posted via http://www.ruby-forum.com/. > > You just made me ponder a cool thing: N = 8 (a = [0, 1]).each_index{|n, i| a << a[i-1] + a[i] if i > 0 and i < N Of course it probably wouldn't work, but... Cool Aur