From: "Peña, Botp" Date: 2006-06-26T18:12:09+09:00 Subject: Re: Some ugly code (again) fr Arnaud: # Can I do nicer than: # # {1..y}.each do |y| # {1..x}.each do |x| # the_name = name + y.to_s + x.to_s # end # end your code is already nice. it is readable to me. "nicer" is difficult to measure :) if you do not like the ".." notation and if you do not like the to_s conversion, you can eg do something like, >cat test.rb y=3 x=4 1.upto(y) do |i| 1.upto(x) do |j| puts "rack#{i}#{j}" end end or y.times do |i| x.times do |j| puts "rack#{i+1}#{j+1}" end end >ruby test.rb rack11 rack12 rack13 rack14 rack21 rack22 rack23 rack24 rack31 rack32 rack33 rack34 kind regards -botp