Extensions add methods to an existing type without changing the original declaration.

Add behavior to a string

extension_methods.swift
extension String {
    func shout() -> String {
        return uppercased() + "!"
    }
}

let word = 
let message = word.shout()

print(message)
extension String {
    func shout() -> String {
        return uppercased() + "!"
    }
}

let word = 
let message = word.shout()

print(message)
extension String {
    func shout() -> String {
        return uppercased() + "!"
    }
}

let word = 
let message = word.shout()

print(message)
extension method An extension method is called like a normal method on values of the extended type.