Extensions
Extensions add methods and computed properties to existing types.
Example
extension Int {
var isEven: Bool { self % 2 == 0 }
func squared() -> Int { self * self }
}
print(4.isEven, 5.squared())Exercise
Extend a type.
Int { }Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.