From: Dan Zwell Date: 2008-05-04T12:48:33+09:00 Subject: Re: Different Ways To Loop Don't forget the "traditional" style loop: for x in 1..100 do puts x+1 end ara.t.howard wrote: > > On May 3, 2008, at 8:10 PM, Wyatt Greene wrote: >> 1.upto(100) { |x| puts x } > > > here are a few > > # 1 > puts Array.new(100){|i| i + 1} > > # 2 > i = 0 and loop do > puts i+=1 > break if i >= 100 > end > > # 3 > puts <<-chars.strip.split(%r//).map{|c| c[0]} > \001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\e\034\035\036\037!\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcd > > chars > > # 4 > 100.times{|i| puts i + 1} > > > > a @ http://codeforpeople.com/ > -- > we can deny everything, except that we have the possibility of being > better. simply reflect on that. > h.h. the 14th dalai lama > > > > >