The .split method


#1


please help me. I am stuck on this one.

https://www.codecademy.com/courses/ruby-beginner-en-mzrZ6/0/3?curriculum_id=5059f8619189a5000201fbcb


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"
gets.chomp
puts "Where are you from?"
redact ="New Mexico"
gets.chomp
words (text)
text.split(" ")


#2

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

#3

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.


#4

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


#5

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


#6

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


#7

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