Home > AI > Language > Swift >

CustomStringConvertible

Example (Apple Official)

struct Point {
    let x: Int, y: Int
}


extension Point: CustomStringConvertible {
    var description: String {
        return "(\(x), \(y))"
    }
}

let p = Point(x: 0, y: 10)
print(p)

Leave a Reply