Morton Goldberg
2/17/2008 7:34:00 PM
On Feb 17, 2008, at 10:18 AM, Isaac Toothyxdip wrote:
> [code]
>
> puts "Ok now enter in 5 words, just be sure there are spaces
> inbetween them"
>
> i = 0
> while i < 5
> words_group = gets["","","","",""]
> print "#{words_group[i]}"
> i =+ 1
> end
>
> [/code]
>
> What im trying to do is ask the user to input some words and display
> them using arrays (learning program) i know you could do this easy
> other
> ways but im trying to do it with arrays. What needs to be changed?
Before you change anything you should reach a better understanding of
why your code won't work. The line
words_group = gets["","","","",""]
is interpreted by Ruby as
words_group = gets().[]("","","","","")
That is it means
1. Get a newline-terminated string from STDIN.
2. Call the [] method on that string, passing it five empty strings
as arguments.
The String method [] won't like getting five empty strings as its
argument.
Regards, Morton