Types and Strings
Type Annotations
When the intended type should be explicit, write the type after a colon.
Declare the type you want
type_annotations.swift
let width: Int =
let height: Int = 3
let title: String = "panel"
let area: Int = width * height
let summary: String = "\(title): \(area)"
print(summary)
let width: Int =
let height: Int = 3
let title: String = "panel"
let area: Int = width * height
let summary: String = "\(title): \(area)"
print(summary)
let width: Int =
let height: Int = 3
let title: String = "panel"
let area: Int = width * height
let summary: String = "\(title): \(area)"
print(summary)
annotation
`let name: Type = value` tells Swift the exact type expected for the value.