With
With copied to clipboard
Syntax support is not very good.
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?
Xcode version 11.5
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 🤗
But when I wrote example 1, there was no syntax hint after.init
That doesn't feel good.
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 👍