From: Isaac Toothyxdip Date: 2008-02-20T08:00:38+09:00 Subject: Re: displaying user inputed arrays Ok im trying to check how many words the user inputs to see if its to many like this (>>) places = ['first', 'second', 'third', 'fourth', 'fifth'] puts 'Please enter 5 words on the same line with spaces then press enter:' Way wrote: >>input_words = [gets.chomp.split] >>answered = false >>while not answered >> if input_words.index.length > 5 >> puts "Please type in FIVE words" >> else >> answered = true >> end >>end input_words.each_with_index do |word, i| puts "To view a word you picked type:\n 1: first word\n 2: second word\n 3: third word\n 4: fourth word\n 5: fifth word" answered = false while not answered num_answer = gets.chomp case num_answer[0] when '1'[0] i = 0 answered = true when '2'[0] i = 1 answered = true when '3'[0] i = 2 answered = true when '4'[0] i = 3 answered = true when '5'[0] i = 4 answered = true else puts "Try again...enter a number 1 - 5 to see one of the words you typed" end end puts "The %s word you entered was %s" % [places[i], word[i]] end ive tried many things including putting it after input_word.each_with_index do |word, i| and if i is > 5 then do whatever but i cant figure it out whats wrong with what is going on now because it seems like its saying get the index of how ever many there are and get the length of the index ( i think i could have just done index but i was trying this when i decided to post this ) and if it is greater then 5 dont allow it and i looked at a array tut and you can do that with index or maybe even with indexes why doesnt it work? -- Posted via http://www.ruby-forum.com/.