Ruby online compiler

Ruby 4.0 with the standard library, compiled to WebAssembly. Runs in your browser.

Learn Ruby →
main.rb
# Online Ruby compiler: Ruby 4.0, running in your browser.
# Press Run (or Ctrl/⌘ + Enter). Text in the Input box below is what gets reads.

Player = Struct.new(:name, :score)

team = [Player.new("Asha", 91), Player.new("Ravi", 78), Player.new("Priya", 85)]
best = team.max_by(&:score)
puts "Top scorer: #{best.name} with #{best.score}"

puts team.sort_by { -_1.score }.map(&:name).join(", ")

name = gets&.chomp
puts name ? "Hello, #{name}!" : "Type your name in the Input box."
Output

Press ▶ Run or Ctrl/⌘ + Enter to run your code.

This is the official Ruby (CRuby) built for WebAssembly. There is no network access, gems can't be installed, and each run starts with an empty file system.