I am trying to understand why I can omit the parentheses in the initialization of the class when it takes a block as a parameter.
An example without brackets:
var block = CCActionCallBlock { () -> Void in
NSLog("sedfjsdkl")
}
And here is the formally correct version with brackets:
var block = CCActionCallBlock ( { () -> Void in
NSLog("sedfjsdkl")
})
Both options work as expected, there are no runtime errors or compiler warnings.
In what circumstances can I omit the class initializer brackets? Is this the same code or does it have any side effects? Are there any other syntactic sugars regarding closures / blocks that I should be aware of?
Note. I know that a closure as the last parameter can be written after brackets, but cannot find anything related to the absence of brackets.
, , , / :
var block = MyClass
Update:
-, Xcode .