Labs ICT
โญ Pro Login

Hello, World!

Your first Ruby program.

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
Try it Yourself ->

๐Ÿงช Quick Quiz

What does puts do?