Avatar
StringInterpolation 関係もうまく使えば便利になりそう。 extension String.StringInterpolation { mutating func appendInterpolation<T>(_ val: T?, default defaultValue: String) { if let val = val { appendInterpolation(val) } else { defaultValue.write(to: &self) } } } let value: Int? = nil print("The value is: \(value, default: "<nil>")")