Skip to content
Justice Tech School

Variables and Strings

Variables need no declaration. Double quoted strings support #{} interpolation. Symbols like :name are light, reusable labels. Methods ending in ? return booleans.

Example
name = "Ada"
age = 21
puts "#{name} is #{age}"
puts name.upcase, name.length, name.reverse
puts "ruby" * 3
puts :id.class
puts name.start_with?("A")
puts "a,b,c".split(",").inspect

Result

Ada is 21
ADA
3
adA
rubyrubyruby
Symbol
true
["a", "b", "c"]

Exercise

Insert a value in a string.

puts "Hi #name}"

Quiz Test

Which quotes allow interpolation?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.