Lesson 1 of 11

Hello, Ruby!

Write and run your first Ruby program, and learn the difference between puts, print and p.

In Ruby, you use `puts` (put ) to print to the console with a newline, or `print` if you want no newline. Ruby files end in .rb and are run with the ruby command.

Ruby
puts "Hello, World!"        # puts adds a newline
print "Hello, "             # print does not
puts "Ruby!"                # Hello, Ruby!

# p is like puts but shows the raw representation — great for debugging
p "hello"     # "hello" (with quotes)
p 42          # 42
p [1, 2, 3]   # [1, 2, 3]
p nil         # nil
Bash
# Save as hello.rb, then:
ruby hello.rb
Finished reading?Mark it done to track your progress.

Tip: use the ← and → keys to move between lessons.