Swimat icon indicating copy to clipboard operation
Swimat copied to clipboard

Is there any way to support custom operator?

Open acecilia opened this issue 9 years ago • 1 comments

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!

acecilia avatar Jun 24 '16 23:06 acecilia

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.

Jintin avatar Jun 26 '16 01:06 Jintin