Ruby - Introduction Keyboard Input

Introduction

The simplest way to get external data into a program is to read from console. For example:

Demo

puts "type something:"
a = gets 
puts a

Result

gets accepts a single line of data from the standard input.

The code then assigns the data to variable a and uses puts to output.

Related Topics