Ruby is a dynamic, reflective, object-oriented programming language known for its simplicity and productivity. It's often used for web development, scripting, and more.
Here's a basic "Hello, World!" program in Ruby:
puts 'Hello, World!'
Ruby supports variables and operations similarly to other languages:
a = 10
b = 5
sum = a + b
product = a * b
puts "Sum: #{sum}"
puts "Product: #{product}"
Using conditional statements in Ruby:
number = 10
if number > 0
puts 'The number is positive.'
else
puts 'The number is not positive.'
end
Example of a loop in Ruby:
5.times do |i|
puts "Number: #{i + 1}"
end