Skip to content
KodeTrail

Camp 1 · Step 2 of 12

Hello, Ruby!

puts, p, string interpolation, and Ruby's gentle conventions.

10 min+50 XP

Ruby's basics are famously gentle — no semicolons, no braces around everything, no main function. A file of statements is a program.

Printing

RubyCloud run
  • puts — print plus newline (your default)
  • print — no newline
  • p — a debugging variant that shows values as code (strings with their quotes) — you'll appreciate it soon

Variables and interpolation

RubyCloud run

No let, no var, no type declarations — assignment creates the variable. Inside double-quoted strings, #{...} interpolates any expression. (Single-quoted strings stay literal — a deliberate choice you control.)

Naming and comments

# comments start with a hash
total_steps = 9500        # snake_case for variables

Ruby convention is snake_case, same as Python. Notice how little punctuation survives: Ruby trusts newlines to end statements.

Checkpoint

What does: puts "total: #{2 + 3}" print?

Checkpoint

The difference between puts and print is…

What's next

The idea that explains all of Ruby: everything — numbers, strings, even nothing — is an object.