Learn Ruby: Don't understand how I "answer the question" to run it further? Where and how do I enter first name


#1

Sorry I know this question has been asked before but I am very stuck.

LEARN RUBY
this is the code:
print "What’s your first name? "
first_name = gets.chomp

these are the instruction-
Declare a variable first_name and set it equal to gets.chomp.

This checkpoint may seem like it’s running forever, but the terminal to the right is actually waiting for input because of gets.chomp. Answer the question in the terminal and press “Enter” or “Return” to finish checking your work.

link-https://www.codecademy.com/courses/learn-ruby/lessons/putting-the-form-in-formatter/exercises/getting-input?action=lesson_resume

What does it mean when it says “answer the question in the terminal” and then press enter. Where and how do I answer the question?

Thanks


#2

getting_input

When we Run the program the first line to the screen asks for our first name. We can type immediately to the screen (as indicated by the blinking cursor which means waiting for input from the keyboard). If you cannot, then click right beside the question mark and the cursor should start to blink.

Aside

Think of the window as having multiple panes, and each one with its own virtual world (in programming we call that a namespace). When we click the Run button, we engage the terminal which now becomes the active pane. The terminal is running our code, imperatively, and in the order in which we wrote it.

Sometimes you will run across the term ‘console’, which is essentially the same thing so the two terms are synonymous. console <=> terminal behave in much the same way. In my mind I separate the two terms thus:

A console has a language that it runs commands in, these commands are interpreted for the terminal which runs commands IT is expecting to see, in the language of the mainframe. I know that’s splitting hairs, and really has no importance. It’s just my view of it. A console operates within a confined environment; a terminal operates in the same environment as the computer it is engaged with.

What happens when we press Run?

The CC program (handler) that intercepts our click of that button passes our data (the program code in file form) to the bash shell with ruby as the prefix followed by the file name.

ruby script.rb

The shell is the terminal that communicates directly with the computer (OS). We’ve just told it what kind of namespace to initialize and what script to run in it.

We didn’t do that directly, but the handler did. We click, the handler handles, and this is where we arrive… In the shell, or bash namespace with our program running and awaiting keyboard input.


#3

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