Lesson contents

Store a value

Give a number a name so you can use it again.

Simple example

Start5
Result5
main.swift
let seats = 5
print(seats)
Output
5
Advertisements

Everyday examples

A bus has 12 seats. Five are taken. How many seats are free?

Start12 − 5
Result7
main.swift
let seats = 12
let taken = 5
print((seats - taken))
Output
7
Run the example
Terminal
swift main.swift
Official documentation