CAN I USER INPUT?

Capsule Coding
3 min readFeb 28, 2020

Finding out how to use user input was a struggle but I finally made it. I tried watching a couple of tutorials and my attention span was destroyed by advertisements. After a couple of push ups and some brief tea time with my son, I finally realized what i was doing.

User Input is basically having the user, input information within the program, and collecting it as data, To retrieve the data we use a method“gets” to fetch the information for us.

There are different things that you can ask the user to give you and different keywords . Well cover a few

Simple understanding of receiving user input can look like this

1. Puts “Type Your Name:” in the picture below ruby has executed the first line puts “Type your Name” . Next the user will type in their name, hopefully in text, in the terminal …

2. name = gets

# 2 is the magic, no picture for this one guys, this is where the user will input their answer and the gets process begins.

3. puts (“Welcome Back”+ name)

# 3 Here RUBY is tired, it is done Running thee entire ruby file. We get our USER INPUT back and it is WELCOME BACKChris.

See how Back and Chris are touching together?

To get rid of that I’m not sure

but here’s my email

(thisistheway369@icloud.com)

I hear pair programming helps you learn to code quicker?!

Look At A few examples of how to use gets. Using different methods to edit our user input once we receive it..

.capitalize on the LEFT ,AND .upcase on the RIGHT.

There are other methods to add to your gets method depending on what you are trying to achieve.Below this sentence are a few used in numeric inputs.

.chomp

to_i

Also

If you search on google you can learn many more different ways to use methods! I’d love to sit here and make it easy but I learned by applying myself, and don’t forget my email is somewhere on this blog post if you read. Well this is ruby so if would be right if I didn’t leave you with a “gem”. A good site i found on my path to understanding Ruby. It’s probably nothing to you but I’m sure someone will find it useful.

Good Luck!

……………………….THANK YOU & DON’T STOP CODING………………….…

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Capsule Coding
Capsule Coding

No responses yet

Write a response