Skip to content
Omni Academy
Search courses and lessons
Search
Courses
Backend Development
9
Databases
1
Frontend Development
5
Data Science
5
All courses →
Playground
HTML & CSS
JavaScript
TypeScript
Python
PHP
Ruby
Light
Dark
Auto
Sign in
Get started
All
Backend Development
Databases
Frontend Development
Data Science
Playground
Blog
HTML
JS
TS
PY
PHP
RB
← Courses
📄
Reading input
Run as I type
Reset
▶
Run
Ctrl
↵
RB
Ruby source code
# gets reads the Input box below the editor - one line per call. # Two lines are waiting there already; change them and run again. name = gets.chomp year = Integer(gets.chomp) age = 2026 - year puts "Hello, #{name}." puts "You turn #{age} this year." puts(if age >= 18 "Old enough to vote in most places." else "#{18 - age} years until you can vote in most places." end) # Integer() raises on anything that is not a whole number, which is what # you want. to_i would quietly return 0 instead. begin Integer("not a number") rescue ArgumentError => e puts "ArgumentError: #{e.message}" end
Input
one line per
input()
call
Aisha 1997
Output
Rendered by your browser