From: Martin DeMello Date: 2008-02-21T07:09:52+09:00 Subject: Re: displaying user inputed arrays On Wed, Feb 20, 2008 at 12:19 PM, Isaac Toothyxdip wrote: > Im not really wanting it to take only the first 5 words i want it to say > something if it is more then 5 words > > print "Please type in 5 words with spaces inbetween them: " > > answered = false > while not answered > a = [gets.chomp.split] > if a.length > 5 > puts "Type in FIVE words no more:" You're very close - it's simply a = gets.chomp.split (without the square brackets). I recommend splitting on " " explicitly rather than relying on it being the default. a = gets.chomp.split(" ") Note that what you did was create an array containing the return value of gets.chomp.split: input = "hello world" a = input.split #=> ["hello", "world"] a = [input.split] #=> [["hello", "world"]] in the latter case, you get an array of length 1, whose only element is an array of length 2. martin