# Gets and chomp method question

**URL:** <https://www.ruby-forum.com/t/gets-and-chomp-method-question/88031>\
**Category:** Ruby\
**Created:** [March 28, 2006, 12:34am UTC](https://www.ruby-forum.com/t/gets-and-chomp-method-question/88031 "2006-03-28T00:34:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 28, 2006, 12:34am UTC](https://www.ruby-forum.com/t/gets-and-chomp-method-question/88031/1 "2006-03-28T00:34:31Z")

</div>

I’m working through the “Gets and chomp method” section of Learn to  
Program on [Mixing It Up - Learn to Program](http://pine.fm/LearnToProgram/?Chapter=04)

I have a problem. I have entered the strings:  
puts ‘Hello there, and what's your name?’  
name = gets  
puts 'Your name is ’ + name + ‘? What a lovely name!’  
puts 'Pleased to meet you, ’ + name + ‘. :)’  
into the text editor, and when I run it, it of course runs up to the  
second line. At this stage, I’m supposed to get a question, “What’s  
your name?” and respond by typing in my name.

When I run it, the command box opens, and just stays there. I have  
tried typing my name in there, but nothing happens, and I cannot get  
the code to continue running.

Where am I supposed to type in my name, and what am I supposed to type  
to get the code running through the remaining lines of code?

Thank you.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 28, 2006, 1:06am UTC](https://www.ruby-forum.com/t/gets-and-chomp-method-question/88031/2 "2006-03-28T01:06:20Z")

</div>

removed\_email\_address@domain.invalid wrote:

> your name?" and respond by typing in my name.
> 
> When I run it, the command box opens, and just stays there. I have  
> tried typing my name in there, but nothing happens, and I cannot get  
> the code to continue running.
> 
> Where am I supposed to type in my name, and what am I supposed to type  
> to get the code running through the remaining lines of code?
> 
> Thank you.

Where are you running the program from? Inside some IDE? From the  
command line? In Windows?

-Justin

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 28, 2006, 1:07am UTC](https://www.ruby-forum.com/t/gets-and-chomp-method-question/88031/3 "2006-03-28T01:07:41Z")

</div>

Justin C. wrote:

> > second line. At this stage, I’m supposed to get a question, "What’s
> 
> Where are you running the program from? Inside some IDE? From the  
> command line? In Windows?
> 
> -Justin

Nevermind, I see you are running Scintilla and I don’t know anything  
about that! 🙂

-Justin

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 28, 2006, 1:19am UTC](https://www.ruby-forum.com/t/gets-and-chomp-method-question/88031/4 "2006-03-28T01:19:08Z")

</div>

removed\_email\_address@domain.invalid wrote:

> your name?" and respond by typing in my name.
> 
> When I run it, the command box opens,

You ought to be running it from the command-line interpreter.  
The IDE is not part of Ruby.

> and just stays there. I have  
> tried typing my name in there, but nothing happens, and I cannot get  
> the code to continue running.
> 
> Where am I supposed to type in my name, and what am I supposed to type  
> to get the code running through the remaining lines of code?
> 
> Thank you.

Above the code that you typed, this appears:

What actually happens is that gets just sits there,  
reading what you type until you press Enter.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 28, 2006, 2:42am UTC](https://www.ruby-forum.com/t/gets-and-chomp-method-question/88031/5 "2006-03-28T02:42:58Z")

</div>

> > > puts 'Pleased to meet you, ’ + name + ‘. :)’

Hi,

I’ve never used Scintilla myself but I tried to run your program.

It seems Scintilla has a small splitter on the right. If you drag it to  
the  
left, this is the place where your program will write with puts… And  
it’s  
also there that you type your input (for gets). You have to ignore the  
command prompt window that will start… (The splitter can also be at  
the  
bottom depending on the options…)

You won’t see anything before you type if you leave your program that  
way.  
This is because Ruby will wait for more text before printing it because  
it’s  
more efficient this way. So you can do this to force Ruby to write the  
text  
before you wait for the user input:

puts ‘Hello there, and what’s your name?’  
STDOUT.flush  
name = gets  
puts 'Your name is ’ + name + ‘? What a lovely name!’  
puts 'Pleased to meet you, ’ + name + ‘. :)’

You normally don’t need that outside Scintilla…

Hope this helps. Good luck!

Guillaume

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 29, 2006, 1:50am UTC](https://www.ruby-forum.com/t/gets-and-chomp-method-question/88031/6 "2006-03-29T01:50:45Z")

</div>

> paul.denlinger@… wrote:
> 
> I’m running it from the SciTE editor which comes bundled with Ruby.

Hi,

SciTE is (kinda) Scintilla, so my answer still applies… Just replace  
Scintilla with SciTE in my reply 🙂 … You can see my reply there if  
you  
didn’t see it:

[http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/186287](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/186287)

Guillaume

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 28, 2006, 5:34pm UTC](https://www.ruby-forum.com/t/gets-and-chomp-method-question/88031/7 "2006-03-28T17:34:04Z")

</div>

I’m running it from the SciTE editor which comes bundled with Ruby.
