Ruby code

Press Ctrl/Cmd + Enter to run. Auto-run reruns 700 ms after editing. Enable Monaco for highlighting; it loads from a CDN only when requested.

The Ruby 3.4 WASI runtime (ruby.wasm 2.10.1) downloads from jsDelivr on Run. The binary is approximately 16 MiB before compression. Prepare standard input before Run; no live terminal, gem installation or native OS processes. Runtime notices.

Code examples (20)

Click an example to add it above your code. Existing code stays; Auto-run is paused. Clear the editor first if you want to run only the example.

Basics

Number exercises

Logic exercises

Arrays and search

Functions and OOP

Star patterns

Plain editor
0 lines · 0 chars

Output

Use STDIN.readline to read the prepared standard input. Runs in a Web Worker, without direct DOM access. Stop terminates execution; each run has a 30-second execution limit and output is capped at 500 rows. Code can still make network requests, so only run code you trust. The tool does not save or upload your code or input.

Learn

Ruby Playground Guide

About this tool

Run Ruby 3.4 in a disposable browser Worker using ruby.wasm 2.10.1 and a WASI adapter. The runtime downloads from jsDelivr only on Run or when Auto-run is enabled. Exercises cover arithmetic, logic, arrays, classes and pyramid patterns. Code and input are not saved or uploaded by the tool. Ruby’s JavaScript bridge can still access browser APIs and make requests; only run code you trust.

Questions

How do I read input?
Fill Standard input before Run, one answer per line, then use STDIN.readline.chomp. Missing answers raise EOFError. This is prepared input, not a live terminal.
Why does the first Run take longer?
The Ruby WASM binary is approximately 16 MiB before compression. It downloads from jsDelivr and initializes in a fresh Worker. Runtime loading has a 90-second timeout, followed by a separate 30-second execution limit. Normal HTTP caching can reuse assets between runs.
Can I install gems or run Rails?
This runner provides a browser WASI build, not a desktop Ruby installation or a web server. No gems are installed automatically; arbitrary native extensions and OS subprocesses are unavailable.
Does selecting an example erase my code?
No. It adds code above the existing snippet and pauses Auto-run. Clear first to run just the example. Ruby examples share the snippet’s namespace, so later definitions can replace earlier ones.
Is this a security sandbox?
No. A Worker prevents direct DOM access and can be terminated, but Ruby’s JavaScript bridge can make network requests. The tool itself does not upload or persist code or input. Each Run starts fresh; output is limited to 500 rows.