Smarter introduce variable refactoring for Ruby
RubyMine 2.5 features an improved procedure for introducing variables, fields or constants. You no longer need to select the block you want to create a variable from. Instead RubyMine gives you options.
The code example below could probably be improved a bit by introducing some local variables.
So, we put the caret on the
computer_players and invoke Refactor->Introduce Variable. It opens a popup with several options:
While we move through the options RubyMine highlights the expression that will be extracted as a new variable:
Let’s pick the
RubyMine surely sees that there are several occurrences and suggests to replace them all:
Once we finish, the code looks like below with a new
first_player variable. Voila!
Develop with pleasure,
JetBrains RubyMine team
Subscribe to Blog updates
Thanks, we've got you!