Ruby Programming – 8 – gets.chomp Method

Today we’ll be going over the method gets.chomp. It will allow us to get a users input to create variables.



Twitter ►

YouTube ►

Facebook ►

SoundCloud ►

★☆★ NOTES ★☆★


CL Barillas says:

Hi Jake.  I’m going through your series of tutorials.  You’ve indicated a couple of times that you’ll list books you recommend on Ruby programming.  It’s probably me, but I haven’t found them yet.  Do you mind telling me what they are?  Thanks!

Bob Jasinski says:

excellent work , I agree

oldkingjames oldkingjames says:

.When you type in your input and press your enter key the enter key also has its byte added. The chomp takes the character/byte out from the input. Do not forget the full stop -period if American – before chomp (.chomp )

therealbobisme says:

yay! i’m the first! nice tuts easy to understand, i look forward to seeing the rest 🙂

Lewis Creelman says:

I’m using the ruby app on my iphone, it’s doesn’t like chomp?

Patricia K. says:

Oh I’m so excited about coding now! 😀 I’m having so much fun watching and following along with your videos. Thank you for making these! <3 

Dan Kreiger says:

how can you use gets.chomp to get input from a browser window (not the terminal) 

i’m struggling with rails and connections the frontend with the backend – i love the gets.chomp method but i can’t seems to make it practical in ruby on rails

Matthew Tiezzi says:

I keep getting “assigned but unused variable – user_input”.  When I run it I get an Error  FAIL: SIGTERM.  I typed it in exactly as on the screen.  Please help.

Keith Chong says:

I love you

tin nguyen says:

Not a problem . Do you have a box office? 

Michael Smith says:

Just started a boot camp and am very grateful I found your teachings. You are so slow and neat with a very clear strong voice.

Charles Yaafi says:

why didn’t you use puts instead of print

QDOS Nostalgie says:


Budimir Krivokuca says:

I started to learn Ruby and for beginners this is best guide i found so far. U made your videos very good, cant wait to finish them all. (y)

tin nguyen says:

I would like to thank you for sharing knowledge and doing an excellent job at it. My deepest appreciation goes to you Jacob. When I do make big money because of this trust me you wont be forgotten.  

TheMilohemlock says:

Thanks for taking the time to do this. Much respect.

Sian Muan Thang Milun says:

I am coding on Sublime Text 3. gets.chomp doesn’t work on it. Please help!

Haitham Mogherbi says:

Jake thank you so much for the videos

Ryan Zhou says:

Great stuff man! 

Daniel Chikaka says:

Thanks +Jacob Williams 

Xipu Li says:

What if you don’t have a middle name? If you put nothing after “Middle name?”, it will result in double spaces between first and last names.

UnknownSubscriber says:

Hey Jacob,  I can’t find the video you’re talking about at the end of this one, where you can automatically be inputted into all the contests.  Could you send a link please?  Thanks.

tenybeny says:


ninja proxy says:

I like to play with my code and change things up it’s really fun thank you.


You never explained what  .chomps did !

Just a Hack says:

sir can you make a vide on how to buy a domain name with dedicated server actually me and my friends know about domain name but dont know about dedicated server how to use dedicated server on windows or mac to hold all the data please help us and by the way your tutorial are awesome…

Gregory Laskaris says:

Where are the books?

Ohio Odion says:

So excited!!! Can’t wait to learn more…
 Thank you for the tutorials!

ianciti says:

your voice sounds a LOT like James Woods, there are times that i keep thinking i’m in the middle of white house down or once upon a time in america.

Nadia Soebiakto says:

Thank you!

Rohan Kapuria says:

Hey Jacob, something interesting I noticed if you type
print “Please type your first name”    (Notice here I don’t have a period at the end)
user_input = gets.chomp
puts “Your first name is #{user_input}!”

If I run this program it will ask for my name but it wont return it. Only if I put period at the end of the print statement it will return my name. So I am guessing that a period is mandatory ??

D. Solward says:

Liked and subbed, this series is awesome. THANK YOU!! 😀

Сергей Иваненко says:

Thanks for simple and beautiful lessons =)

Håvard Nygård says:

Most usefull line of code to now in my opinion 😛

The noob says:

You could also explain why the chomp method is used with gets.

The reason why chomp is used when getting input is because each input you get adds a new line after, to get rid of it you have to use the chomp method so you only get the user input.

Rico Ferdian Alexander says:

Wew I started to feel that ruby is more and more flexible than C++, the capitalize method is very nice, either it is flexible or the rules are not so monstrous like in C++,  yi er san yi er san, let’s dig in more lesson.. hehe

Everything Awesome says:

JAKE question! i have a working basic client and server and im trying to use what i’ve learned from your videos in this script but its not working. it’s not giving me an error either. here is the code its very short and simple.

require “socket”
server =“localhost”, 2000)
loop {

thread.start(server.accept) do |nodervcr|
msg = nodervcr.gets
puts (msg)

but when I add in that loop , a series of if then else commands, it does NOT recognize what I want it to ( nor anything for that matter) ; It’s acting as if “nodervcr” is only good for that firts “puts(msg) after that i can’t use it! whats going on here? how do i get the incomign message from the client as a variable so i can redirect the script accordingly?

 Write a comment


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!