From: Zoe Phoenix Date: 2008-07-18T14:05:27+09:00 Subject: inserting a random item from an array I'm trying to have Ruby generate a random list of 30 links to put at the bottom of a web page and write it to a file. I think I'm on the right track of how to do it, but I'm not sure... ############## citylist = ['Orlando', 'Tampa', 'Fort Lauderdale', 'Miami', 'St. Petersburg', 'Etc.' ] output = 30.times do [rand(citylist.length)] %Q(Website #{rand(citylist.length)} | ) end File::open("I:\\My Documents\\Stuff\\More Stuff\\websitelinks.txt", 'w') do |f| f.write output end ############## I may be mistaken about the use of the block here... Someone please tell me what I'm doing wrong and how to fix it? The two instances of the city inside the block should be the same, but I'm not sure how to do that. Doesn't rand make it a random city each time it's interpreted or since it's in a block, would it be the same each time the block repeats..? -- Posted via http://www.ruby-forum.com/.