Split Initialization from Declaration
Breaks an initialized declaration for a local variable into a declaration and a separate initialization statement.
#Purpose
This refactoring is useful when you need to conditionally initialize a local variable which is currently being initialized inside its declaration. Splitting the initialization from the declaration is the first step in moving toward conditional initialization.
#Availability
Available from the context menu or via shortcuts:
- when the edit cursor, or caret is on a local variable declaration that includes an initialization expression.
#Notes
- This refactoring is the functional opposite of Move Initialization to Declaration.
#Options
- You can control whether the initialization should be placed right below the local variable’s declaration or right above this local’s first use.
#Example
│int a = 10;
│Dim a As Integer = 10
Result:
int a;
a = 10;
Dim a As Integer
a = 10
#Animation
See Also