πŸŽ“ A1Learner
πŸ”

Ruby Introduction

Ruby is a programming language. Programs are plain text files that end in .rb.

A first program

A Ruby program is plain text in a file. This program prints one line of text.

puts "My first Ruby program"

Two lines in order

Two puts statements run in order. The first line prints before the second line.

puts "First line from Ruby"
puts "Second line from Ruby"

Example

puts "Ruby is a programming language"
puts "Ruby files end in .rb"
puts "Ruby can print text"

Key points

  • Ruby code is plain text in a file.
  • Ruby files use the .rb ending.
  • puts prints a line of text.
  • Each puts statement prints one line.

In this example, three puts statements run in order. The first statement prints a line that names Ruby as a programming language. The second statement prints the file ending line. The third statement prints a line about printing text.

Try it Yourself

Edit the code, then press Run.

Running is simulated Β· Programiz Ruby Compiler

Exercise

What does puts do in Ruby?