Hi,
I have a question about assigning the contents of a list of variables
with names like title1, title2, title3 up to title20 to an array.
Currently, this is the code that I use.
title1 = ruby
title2 = rails
title3 = typo
.
.
.
title20 = ajax
title_array = [title1, title2, title3, title4, title5, title6, title7,
title8, title9, title10, title11, title12, title13, title14, title15,
title16, title17, title18, title19, title20]
title_array.each do | i |
do something...
end
Is there a shorter way to do this? Instead of typing all the variable
names, can I use a range to do this? Like title(1..20)?
Thanks for any help with this.
--
Posted via http://www.ruby-forum.com/.