有没有办法简化 Swift 尾随闭包的输入? [英] Is there a way to simplify typing Swift trailing closure?

查看:32
本文介绍了有没有办法简化 Swift 尾随闭包的输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尾随闭包使代码更具可读性,但编码过程一点也不愉快.例如,当我想输入这种只接受一个闭包参数的方法(如下所示)时.没有选择尾随闭包的代码提示:

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?

推荐答案

输入 ENTER 两次,一次完成方法名称,第二次自动格式化闭包.

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:

按一次 ENTER 后:

然后,在第二次按下 ENTER 后:

Then, after hitting ENTER a second time:

总结:输入函数的第一个字母,等待自动建议,然后按 ENTER 再按 ENTER.

To sum up: type the first letters of the function, wait for auto-suggest, then hit ENTER then ENTER again.

这篇关于有没有办法简化 Swift 尾随闭包的输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆