Swift Language Typealias typealias for other types

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

typealias Number = NSNumber

You can also use a type alias to give a type another name to make it easier to remember, or make your code more elegant.

typealias for Tuples

typealias PersonTuple = (name: String, age: Int, address: String)

And this can be used as:

func getPerson(for name: String) -> PersonTuple {
    //fetch from db, etc
    return ("name", 45, "address")
}


Got any Swift Language Question?