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

Syntax support is not very good. #2

Open
XiaoJianXiaoXu opened this issue Jul 22, 2020 · 5 comments
Open

Syntax support is not very good. #2

XiaoJianXiaoXu opened this issue Jul 22, 2020 · 5 comments

Comments

@XiaoJianXiaoXu
Copy link

For example,

//EXAMPLE 1:
let rectangle: CGRect = with(.init(x: 0, y: 0, width: 100, height: 100)) {
  $0 = $0.offsetBy(dx: 20, dy: 20)
  $0 = $0.insetBy(dx: 10, dy: 10)
}

Actual, it's better for syntax support.

let rectangle: CGRect = with(CGRect.init(x: 0, y: 0, width: 100, height: 100)) {
   $0 = $0.offsetBy(dx: 20, dy: 20)
   $0 = $0.insetBy(dx: 10, dy: 10)
}

Is there any way to support it?

@XiaoJianXiaoXu
Copy link
Author

Xcode version 11.5

@eonist
Copy link
Owner

eonist commented Jul 22, 2020

using implicit .init is actually preferred over explicit CGRect. If you use a solid Linter it ill complain. The argument is:

  • No need for writing CGRect twice
  • Explicitly setting the type with the variable, improves compile times
  • Using dot notation .init avoids lint complaints
  • dot notation is encouraged (swifty)

But you can use CGRect.init, or CGRect as well 🤗

@XiaoJianXiaoXu
Copy link
Author

But when I wrote example 1, there was no syntax hint after.init

@XiaoJianXiaoXu
Copy link
Author

That doesn't feel good.

@eonist
Copy link
Owner

eonist commented Jul 23, 2020

its called dot notion. Its very common. The style you code in is up to you 👍

You can use the style in your example as well. All 3 variations will work 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants