EKOSM EKOSM - 11 months ago 52
Ruby Question

add to the end of line character in a loop ruby

Have a string, and a range of numbers.Start = 2

stringl = line
numbers = 20
arraystring = []
numbersi=2
if numbersi < numbers
numbersi += 1
arraystring << stringl+numbersi


It is necessary to get an array of

arraystring=[line2, line3 ... line20]

Answer Source

try this:

arraystring = []
for i in 2..20
   arraystring << 'line' + i.to_s
end