vim-ruby-refactoring icon indicating copy to clipboard operation
vim-ruby-refactoring copied to clipboard

RExtractMethod passes in block variables when the block is entirely within the extracted block

Open tom-pang opened this issue 14 years ago • 2 comments

Inside the following method:

def validate(numbers)
  bar = 1
  numbers.any? do |n|
    n < 0
  end
end

,with

numbers.any? do |n| n < 0 end

When I do extract method, and give the new method a name of "check_numbers", I get the following:

def check_numbers(n,numbers)
  numbers.any? do |n|
    n < 0
  end
end

def validate(numbers)
  bar = 1
  check_numbers(n,numbers)
end

Instead, I expect:

def validate(numbers)
  bar = 1
  check_numbers(numbers)
end

def check_numbers(numbers)
  numbers.any? do |n|
    n < 0
  end
end

tom-pang avatar Jun 01 '11 20:06 tom-pang

Note that the temp is needed here, without it, the refactoring works as expected.

tom-pang avatar Jun 01 '11 20:06 tom-pang

Cheers Tom, I'll take a look at this one

nrocy avatar Jun 01 '11 20:06 nrocy