Language
Version: 2.2.0
Categories
-
User Program Communication
-
Variables
-
Control Flow
-
Functions and Blocks
-
Object Oriented Programming
User Program Communication
User Input in Ruby
Used to get information from the user during runtime.
Syntax
variable = gets #includes newline character, or \n
variable = gets.chomp #'chomps' newline character
Notes
The 'gets' keyword must be used with the assignment operator.
Example
puts "What is your name?"
name = gets.chomp
puts "Welcome, #{name}!"