Basic Syntax in Ruby
In this tutorial, we will learn the basic syntax of Ruby language. We will go through the key components of a simple Ruby program.
Output
Hello, World!
Basic Syntax of a Ruby Program
puts "Hello, World!"
This line uses theputs
method to output the string "Hello, World!" to the standard output (usually the console).
Key Points to Remember
- Ruby statements can end with a semicolon (
;
), but it's often omitted and optional. - Ruby is case-sensitive, meaning that
puts
andPUTS
would be considered different. - Comments can be added using
#
for single-line comments or=begin ... =end
for multi-line comments. - Ruby is known for its concise and readable syntax, as well as its flexibility and object-oriented nature.