3/7 Get.chomp


#1

Syntax:

print "What's your first name?"
first_name = gets.chomp

Question: How does Ruby know that when I enter an answer for "What's your first name?" to push that input into the variable 'first_name' ? In essence, what is gets doing to transfer my input from the line above to the first_name variable?


#4

Nothing. The gets method doesn't transfer anything from the line above.

The print method displays the question and the gets method asks for input itself. Since we used gets with the operator =, the return of gets will be stored in the variable.