Camp 1 · Schritt 2 von 12
Hello, Ruby!
puts, p, string interpolation, and Ruby's gentle conventions.
10 Min.+50 XPAuf Englisch angezeigt — Übersetzung ist unterwegs
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 newlinep— 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 variablesRuby 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.