With the Extract Closure refactoring (Swift), you can create a closure based on the selected chunk of code. Select an expression to extract, then press &shortcut:Refactorings.QuickListPopupAction; and choose Extract Closure:

In the dialog that opens, type the name of the new closure and change the parameter names and types if needed.
This will result in the following:
