Closed NikKovIos closed 2 months ago
This should work:
infix operator +?
extension Int {
static func +? (a: Self?, b: Self) -> Self? {
if let a { a + b } else { nil }
}
}
The idea is that operators should be static and associated with the type. But the operator declaration needs to go to file scope. It cannot be part of the extension.
Work!
Can't figure out how to declare infix operator without warning. Help please.