The .split method


please help me. I am stuck on this one.

when I type my name and where I am from I receive this error
undefined method `words' for #

puts "What is your name?"
text = "Stephen"
puts "Where are you from?"
redact ="New Mexico"
words (text)
text.split(" ")


This method will get a string from the user, and chomp the newline character.

We still need to cache that string somewhere.

text = gets.chomp

Now we have a retrievable copy of that string cached in a variable, text.

puts text    # This is the string I typed in at the input prompt


your advice is referring to the second gets.chomp that would collect the user input for "Where are you from"? is that right?
I am still a little confused.


It is general advice. gets needs to be captured else it just happens and there is no record of it.


can you provide an example of "captured" I am not as familiar with that term referring to .gets
thank you


'captured', is a verb, past tense. Would it be easier to envision as, 'stored'?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.