19 lines
903 B
Markdown
19 lines
903 B
Markdown
## Mastering the IDE: More Intentions
|
|
|
|
You can automatically convert a function with a block body to a function with
|
|
an expression body, and vice versa. Put the caret somewhere on the `return`
|
|
keyword, press <span class="shortcut">&shortcut:ShowIntentionActions;</span>
|
|
to call the intention actions menu, and choose
|
|
<span class="control">`Convert to expression body`</span>.
|
|
After the conversion the type remains highlighted, which is
|
|
convenient because you can either remove the type declaration by pressing
|
|
`Delete` or leave it by moving the caret to the right.
|
|
|
|
To apply the reverse intention, press
|
|
<span class="shortcut">&shortcut:ShowIntentionActions;</span>
|
|
on the equal sign on the function with expression body and choose the
|
|
reverse conversion.
|
|
|
|
Apply <span class="control">`Convert to expression body`</span>, and then
|
|
<span class="control">`Convert to block body`</span> intention actions.
|