Ruby Get Started
Getting started is the path from a written Ruby file to printed output. The steps stay the same for every program in this course.
The full shape
The full shape is one file with one statement. The statement prints one line.
puts "Let's get started"Two statements in order
Two statements run from top to bottom. Each statement prints one line.
puts "Step one"
puts "Step two"Example
puts "Program started."
puts "Program finished."Key points
- The Ruby file in this course is named main.rb.
- Use ruby main.rb to run the file.
- A statement is one complete instruction in a program.
- Statements run from top to bottom in order.
- puts prints one line of text.
In this example, two statements run in order. The first statement prints Program started. The second statement prints Program finished.
Try it Yourself
Edit the code, then press Run.
Running is simulated ยท Programiz Ruby Compiler
Exercise
Which command runs the file main.rb?