Your First Ruby Program

Let’s create a simple Ruby script to display text.

Steps:

  1. Create a file named hello.rb
  2. Add the following code:
puts "Hello, world!"

Run the File:

In terminal or command prompt:

ruby hello.rb

This will print:

Hello, world!

puts is a Ruby method used to print output to the console.

← PrevNext →