From: Carlos Date: 2004-11-11T21:23:08+09:00 Subject: Re: array.each restart when array is changed [Kevin B�rgens , 2004-11-10 23.48 CET] > How to restart a "each" iteration when the iterated array is changed? I do > it like this > > changed=false > while (changed) > changed=false > array.each {|e| > if (today_is_christmas) > array=array+=["Hello santa claus"] > changed=true > end > } array.each do |e| if (today_is_christmas) array += ["Hello"] retry end end Beware of infinite loops. > Second question: > why is this not allowed > > #show me the first n letters of the alphabet > ('a'...'a'+gets.to_i).each{|e| puts e } > > How to do it the right way? (?a ... ?a + gets.to_i).each do |e| puts e.chr end letter='a'; gets.to_i.times do puts letter; letter=letter.succ end You have several possibilities. Good luck. --