Thuta Learning
BasicProgrammingbeginner

Syntax & Hello World

Relax. We'll talk through this in plain words — no textbook voice.

Ruby's syntax is clean. You don't need a semicolon at the end of a statement. Parentheses on method calls are optional in some places — but it's still good practice to use them when the parameters matter for readability.

ruby
puts "Hello, World"
puts("This also works")

# String interpolation
language = "Ruby"
puts "I am learning #{language}."

puts prints output followed by a new line. #{language} is called string interpolation — it inserts a variable's value into a string.

You should see
Hello, World This also works I am learning Ruby.

Info

Single quotes ' ' don't support interpolation. If you want to insert a variable's value, use double quotes " " instead.

Easy traps

  • If you write puts 'I am learning #{language}', #{language} will be printed literally as text.
Syntax & Hello World | Thuta Learning