Ruby
Ruby, created in 1995. https://www.ruby-lang.org/
Example
Section titled “Example”puts "=== Ruby Demo: 11 Examples ===\n\n"
# 1. Hello Worldputs "1) Hello World:"puts "Hello, world!\n\n"
# 2. Variables and arithmeticputs "2) Variables & Arithmetic:"a = 5b = 3puts "a = #{a}, b = #{b}, sum = #{a + b}\n\n"
# 3. Arraysputs "3) Arrays:"fruits = ["apple", "banana", "cherry"]puts "First fruit: #{fruits[0]}"puts "All fruits: #{fruits.join(', ')}\n\n"
# 4. Hashesputs "4) Hashes:"ages = { "Alice" => 25, "Bob" => 30 }puts "Alice is #{ages["Alice"]} years old\n\n"
# 5. Conditionalsputs "5) Conditionals:"if a > b puts "#{a} is greater than #{b}\n\n"else puts "#{b} is greater or equal to #{a}\n\n"end
# 6. Loopsputs "6) Loops:"(1..3).each do |i| puts "Loop iteration #{i}"endputs
# 7. Methodsputs "7) Methods:"def greet(name) "Hello, #{name}!"endputs greet("Ruby User")puts
# 8. File handlingputs "8) File Handling (write & read):"filename = "demo.txt"
# WriteFile.open(filename, "w") do |f| f.puts "This is a test file."end
# ReadFile.open(filename, "r") do |f| f.each_line do |line| puts "Read: #{line}" endendputs
# 9. Regular expressionsputs "9) Regular Expressions:"text = "Ruby is powerful"if text =~ /powerful/ puts "Match found in text!\n\n"end
# 10. Command-line argumentsputs "10) Command-line Arguments:"if ARGV.any? puts "Arguments passed: #{ARGV.join(' ')}\n\n"else puts "No arguments provided\n\n"end
# 11. Method using shiftputs "11) Method with shift:"def add_numbers(*args) x = args.shift # first argument y = args.shift # second argument x + yend
result = add_numbers(10, 20)puts "10 + 20 = #{result}"
puts "\n=== End of Demo ==="Famous book
Section titled “Famous book”- “Pickage book”
Famous library/framework
Section titled “Famous library/framework”- Ruby on Rails: https://rubyonrails.org/
Similar to Perl and Python