With icon indicating copy to clipboard operation
With copied to clipboard

Syntax support is not very good.

Open XiaoJianXiaoXu opened this issue 5 years ago • 5 comments

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 avatar Jul 22 '20 08:07 XiaoJianXiaoXu

Xcode version 11.5

XiaoJianXiaoXu avatar Jul 22 '20 08:07 XiaoJianXiaoXu

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 🤗

eonist avatar Jul 22 '20 10:07 eonist

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

XiaoJianXiaoXu avatar Jul 23 '20 01:07 XiaoJianXiaoXu

That doesn't feel good.

XiaoJianXiaoXu avatar Jul 23 '20 02:07 XiaoJianXiaoXu

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 👍

eonist avatar Jul 23 '20 10:07 eonist