Ruby Basics
Store text and print it.
On this page
The concept
Assignment binds a value to a name. String interpolation inserts an expression inside double-quoted text. puts writes a line.
Code example
Ruby
name = "Ada"
puts "Hello, #{name}"Output
Hello, Ada
Follow the code
Open the walkthrough to inspect the example one step at a time.
Show guided walkthrough
Guided walkthroughReady
1
name = "Ada"2
puts "Hello, #{name}"Follow the example
Start to inspect the source, values, and output. These prepared steps explain the published sample; grouped loop steps describe multiple iterations.
View the complete dry-run table
| Step / line | What happens | State after step | Output so far |
|---|---|---|---|
| Assign the string to name. | name = "Ada" | — | |
| Interpolate name and write a line. | name = "Ada" | Hello, Ada |
Behind the scenes
How Ruby processes this code
Ruby parses and executes the script. Blocks run when their methods invoke them.