dgsuarez / reruby

Refactor Ruby
MIT License
35 stars 2 forks source link

Extract method with multiple variables used later #40

Open dgsuarez opened 5 years ago

dgsuarez commented 5 years ago
class Test
  def variables_used_later
    a = 3
    b = a * 3

    a * b
  end
end

Applying extract method to the first 2 lines of the method results in:

class Test
  def variables_used_later
    b = extracted

    a * b
  end

  def extracted
    a = 3
    a * 3
  end
end

a no longer exists in variables_used_later, but it tries to use it.