Ast Jay wrote: > I didn't see a beginners forum - hope it's ok to post this here. > > I feel so daft as this must be the simplest question you've probably > been asked! > > Anyway I'm new to Ruby and want to create a very simple script that > generates 100 random words and puts them into an array. I want to put > them into an array so I can use array.uniq! so there are no duplicates. > Hi and welcome to Ruby and its community! Your code looks good so far. >def create_word > first_letter = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", > "p", "q", "r", "s", "t", "v", "w", "x", "y", "z"].shuffle[0..6].join > end You don't need to create "first_letter". Ruby returns the last expression evaluated -- so when you run that line, it returns a string of seven characters. > def create_list(word) > words = [] > words << word > end Clever! There is however something even CLEVERER! def create_list word # note the parenthesis are optional! [word] end As you can see, there's no need for a method just to do that. > 100.times do > list << create_list(create_word) > puts list > end A "Set" is an array that doesn't accept duplicates. So you can do this: require 'set' list = Set.new 100.times { list << create_word } or... list = [] 100.times { list << create_word } list.uniq! Make sense? -- Posted via http://www.ruby-forum.com/.