Search⌘ K
AI Features

Write Your First Ruby Program

Explore the fundamentals of Ruby programming by writing your first program that prints Hello World, understanding how to use puts for output, and learning to write comments. This lesson also introduces common error types to prepare you for coding challenges ahead.

"Hello World!" in Ruby

Let's first look at the output of the following program by clicking the "Run" button of the widget given below:

Ruby 3.1.2
puts "Hello World!"
# This is a comment that fits on one line
=begin
This second comment
fits
on multiple lines
=end

Explanation

Line 1: We used puts to print the output Hello World! in the console. ...