How can I modify the textual output that gets displayed in string interpolation?
The Printable protocol looks the most obvious but it\'s ignored in both
As an alternative in Swift 5+ you can extend the String.StringInterpolation
struct Point {
var x : Int
var y : Int
}
extension String.StringInterpolation {
mutating func appendInterpolation(_ value: Point) {
appendInterpolation("\(value.x):\(value.y)")
}
}
This will change the value for
print("\(p)")
but not for print(p) - which will still use the description