Swimat
Swimat copied to clipboard
Is there any way to support custom operator?
I have declared an operator as follows:
infix operator ??= { }
func ??= <T>(inout lhs: T, rhs: T?) -> Void {
guard let value = rhs else { return }
lhs = value
}
But after using Swimat I am getting:
infix operator ?? = { }
func ?? = <T>(inout lhs: T, rhs: T?) -> Void {
guard let value = rhs else { return }
lhs = value
}
Which result in a compiler error due to the spaces added. Any workarounds? Thank you very much!
It's easy but you have to do it yourself.
Clone Swimat project and open the SwiftParser.m file
in checkOperator function, add following codes in '?' section:
if ([self isNextString:@"??="]) {
[self spaceWith:@"??="];
}
And build project, reopen Xcode.
If you encounter any problem, please let me know. Thank you.