712 B
712 B
Mastering the IDE: Extract Variable
IntelliJ IDEA can extract a val
or var
automatically. Select the expression
getFooResult()
inside a string template, then do one of the following:
-
Invoke
Find action
(by pressing &shortcut:GotoAction;), then typeExtract variable
to find the corresponding action -
Press &shortcut:IntroduceVariable;;
-
Choose
Refactor | Extract | Variable...
in the application menu.
Type the name of the new variable. IntelliJ IDEA tries to suggest a name based on the expression. Press &shortcut:EditorEnter; to finish.