Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to support custom operator? #112

Open
acecilia opened this issue Jun 24, 2016 · 1 comment
Open

Is there any way to support custom operator? #112

acecilia opened this issue Jun 24, 2016 · 1 comment

Comments

@acecilia
Copy link

acecilia commented Jun 24, 2016

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!

@Jintin
Copy link
Owner

Jintin commented Jun 26, 2016

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 Jintin closed this as completed Oct 4, 2017
@Jintin Jintin reopened this Oct 4, 2017
@Jintin Jintin changed the title Is there any way to apply custom rules? Is there any way to support custom operator? Oct 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants