Trailing closure make code more readable, but the coding process is not enjoyable at all. For example, when I want to type this kind of method (shown below) that only takes one closure parameter. There is no Code hint for choosing trailing closure:
I have to delete content inside()
, and type the complete closure like that :
Is there a way to make this easier?
Type
ENTER
twice, once to complete the method name, a second time to automatically format the closure.When I begin to type the function name:
After hitting
ENTER
once:Then, after hitting
ENTER
a second time:To sum up: type the first letters of the function, wait for auto-suggest, then hit ENTER then ENTER again.
If the closure takes parameters, you just do:
Multiple params:
No params:
For future reference: http://goshdarnclosuresyntax.com