[Ruby] Receive input from console

Progate learning notes

Use gets.chomp

puts "Please enter your name"

#Takes input from the console and assigns it to the variable name
name = gets.chomp
puts "Hello,#{name}Mr."

Console ↓

Please enter your name#Waiting for input

If you enter "Taro",

Hi, Taro

gets.chomp is received as a character string, so if you want to receive it numerically, Use count = gets.chomp.to_i.

reference Progate

Recommended Posts

[Ruby] Receive input from console
[ruby] How to receive values from standard input?
Ruby input / output
From terminal to Ruby (standard input / output)
Ruby standard input
From Java to Ruby !!
Ruby receives multi-line input
Use C program from Ruby
Use Face API from Ruby
Ruby Learning # 10 Getting User Input
CHATBOT (Dialogflow) used from Ruby
Input to the Java console
Learning Ruby with AtCoder 11 How to receive frequently used standard input
Ruby standard input and various methods
[Ruby] Escape from multiple loops [Nest]
Introduction to Ruby (from other languages)