Skip to content

Latest commit

 

History

History
88 lines (62 loc) · 3.92 KB

“Surround with…” comes to Kotlin.md

File metadata and controls

88 lines (62 loc) · 3.92 KB
title date author tags keywords categories reward reward_title reward_wechat reward_alipay source_url
[译]“Surround with…” comes to Kotlin
2013-02-26 01:20:00 -0800
Natalia Ukhorskaya
官方动态
false
Have a nice Kotlin!

对于Intellij IDEA的球迷来说,好消息:“Surroud with ...”动作现在可用于Kotlin!

什么是“Surround with ...”动作?

</ strong>此操作允许您使用环绕一个代码块,如果</ em>,尝试</ em>或其他语句(请参阅 完整列表 下面)。只需选择一个代码块,按 Ctrl + Alt + T </ em>,然后选择适用于Mac的模板( Cmd + Alt + T </ em>): </ span>

{% raw %}

{% endraw %}

IDE将添加必要的代码,并将插入符号放在允许您完成重构的位置:

{% raw %}

{% endraw %}

如果被包含的块包含在块之后使用的变量声明,则它们将被移出该块:

{% raw %}

{% endraw %}

{% raw %}

{% endraw %}

{% raw %}

<iframe allowfullscreen="true" class="youtube-player" height="390" src="https://www.youtube.com/embed/Bwuj15P8yOQ?version=3&rel=1&fs=1&autohide=2&showsearch=0&showinfo=1&iv_load_policy=1&wmode=transparent" style="border:0;" type="text/html" width="640"></iframe>

{% endraw %}

功能文字模板

你可以围绕一个这样的代码块:

{% raw %}

{% endraw %}

如果要“隐藏”块范围内的某些变量,使用此模板创建具有函数类型或本地函数的属性,并且要使用函数文字作为参数调用任何函数。

{% raw %}

<iframe allowfullscreen="true" class="youtube-player" height="390" src="https://www.youtube.com/embed/ufSDvAxo544?version=3&rel=1&fs=1&autohide=2&showsearch=0&showinfo=1&iv_load_policy=1&wmode=transparent" style="border:0;" type="text/html" width="640"></iframe>

{% endraw %}

当模板

您不需要手写</ em>表达手段:您可以简单地选择主题表达式,当(expr){} </ em>“选择”使用环绕“,结果将会:

{% raw %}

{% endraw %}

“Surround with ...”模板的完整列表

当选择代码块时:

  • 如果
  • 如果别的
  • {} - 函数文字
  • 尝试
  • 试着抓
  • try / catch / finally

当选择表达式时:

  • !(expr) - 为布尔值添加否定
  • (expr) - 用括号括起来
  • “$ {expr}” - 用引号括起来
  • when(expr){}

Kotlin M5.1

作为Kotlin M5.1的一部分,我们将尽快发布“Surround with ...”。