Labs ICT
โญ Pro Login

Hello, World!

Your first Ruby program.

1 min read | Ruby Tutorial
โญ

Want the full learning experience?

Get structured courses, certificates, projects, and instructor support with LabsICT Pro.

Explore Pro Courses

Hello World

The classic first program. In Ruby, you use puts to print text with a newline, or print without one. To read user input, use gets. Comments start with #. Semicolons are optional โ€” Ruby doesn't force them on you. Scripts run with ruby filename.rb. There's no main function needed; Ruby executes your code top to bottom.

# Your very first Ruby program
puts "Hello, World!"

# print doesn't add a newline
print "Hello "
print "World!\n"

# Reading input from the user
puts "What is your name?"
name = gets.chomp
puts "Hello, #{name}!"

# Comments start with # โ€” they're ignored by Ruby
# This is a comment
# So is this

๐Ÿงช Quick Quiz

What does puts do?