Foundations
Variables
Ruby variables can hold numbers and strings, then feed later expressions.
Variables
variables.rb
unit_price =
quantity = 3
total = unit_price * quantity
puts "unit=#{unit_price}"
puts "total=#{total}"
unit_price =
quantity = 3
total = unit_price * quantity
puts "unit=#{unit_price}"
puts "total=#{total}"
unit_price =
quantity = 3
total = unit_price * quantity
puts "unit=#{unit_price}"
puts "total=#{total}"
variable assignment
A variable name stores the result of the expression on the right side of `=`.