Use typealias to define tuple type in Swift

Using tuple as return value of method, or adding them to array, I had to write tuple’s label and type every time, so I looked something in the net and found typealias.
    typealias ItemType = ( name:String, price:Int )
    var item: ItemType
    item = ( "apple" , 98 )
    println("\(item.name) , \(item.price) yen")
This makes code simple.

memo : Swift 1.1
Develop | Comments(1) | Trackback(0)
Comment is pending approval.
Comment is pending blog author's approval.