Type Annotations

#typesafelanguage

Overview

Since Swift is a type-safe-language, it always requires to know what type of data you enter.

To define the data explicitly, type in advance, use type annotations

let surname: String = "Lasso"
var score: Int = 0

// In arrays
var albums: [String] = ["Red", "Fearless"]

// In arrays that have different types
var user: [String: String] = ["id": "@twostraws"]

Sources

Videos

Articles / Documents

Last updated