>
> File.open(city_name, 'w') |w|
>   for i in start_number...end_number
>     w.puts i
>   end
> end
>
> File.open(city_name, 'w') |w|
>   (start_number...end_number).each do |i|
>     w.puts i
>   end
> end

Robert, clever idea, I hadn't thought about it that way but I believe 
you forgot "do" before |w| :)


The reason I am using an array is that sometimes I will need to generate 
a secondary file, based off of the same numbers. In the second file I 
will need to iterate over the array and concatenate additional numbers 
onto the front of each value within the array.

Sometimes that number begins with a 0, so I collect start_code with

start_code = gets.to_s

then as the number list consists of integers I also have to convert that 
so I can concatenate the the values together. So I wrote this but this 
only generates an identical file with the altered file name. It seems as 
if start_code isn't being concatenated? I have tried several variations 
and different combinations in and out of block form.

  File.open(city_name + start_code, 'w' ) do |w|
  w.write((numberlist.each { |p|start_code << p.to_s }).join("\n") )

end

-- 
Posted via http://www.ruby-forum.com/.