Tsallaka zuwa abun ciki
Justice Tech School

Type Safety and Aliases

Swift is type safe: a variable keeps its type. typealias names an existing type, and type inference keeps code short.

Example
typealias Score = Int
var s: Score = 90
let inferred = 3.5
print(s, type(of: inferred))

Exercise

Name an existing type.

 Id = Int

Quiz Test

What does typealias create?

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