I Don't Exactly Understand Gets & omp. - Codecademy

Skip to ContentProfile image of anonymousSubmitted by anonymousover 13 yearsI don't exactly understand gets & gets.chomp.

The description of both are not really explaining it thoroughly for me.

Also, when I try to satisfy the objective to (disregard quotations on outside):

“Declare a variable first_name and set it equal to gets.chomp.”

I put this (also disregard outside quotations):

“first_name = “Austin” gets.chomp”

And it gives me this (and again):

“(ruby): syntax error, unexpected tIDENTIFIER, expecting $end first_name = “Austin” gets.chomp”

Could you explain what I am doing wrong and possibly explain gets & gets.chomp a little more in depth?

Answer 50722ccd201e4100020297c5

5 votes

Permalink

You should write : first_name = gets.chomp

“gets” is a method that asks the user to input something. “chomp” is a method that removes the blank line that is automatically created by “gets” after the input.

Profile image of kpwboSubmitted by kpwboover 13 years

3 comments

Profile image of anonymousSubmitted by anonymousover 13 years

Thank you. I was confused because after inputting what I originally did, I inputted what you said I should and it didn’t give me the completed sign.

Profile image of lena.bosakSubmitted by lena.bosakover 13 years

I’ve input first_name = gets.chomp and it doesn’t give me the completed sign either… Could you , please , tell me what is wrong?

Profile image of anonymousSubmitted by anonymousover 12 years

For further elaboration on the “gets.chomp” expression, check out Alex’s response in the following thread: http://www.codecademy.com/forum_questions/514073efffb67cff44004afe

Answer 533309db8c1cccdb2c002f27

0 votes

Permalink

I Know the answer! Type this: first_name = gets.chomp after you did that a little black screen with a white block is coming in the right corner, now type the exact same thing in to the black screen so : gets.chomp and it will give the correct result.

Profile image of arcBlaster63777Submitted by arcBlaster63777almost 12 years

Popular free courses

  • Free course

    Learn SQL

    In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.
    • Checker DenseBeginner Friendly.4 Lessons
  • Free course

    Learn JavaScript

    Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
    • Checker DenseBeginner Friendly.11 Lessons
  • Free course

    Learn HTML

    Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.
    • Checker DenseBeginner Friendly.6 Lessons
Explore full catalog

Tag » What Is Chomp In Ruby