Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tcrayford opened this issue Jun 1, 2011 · 2 comments
Assignees

Comments

@tcrayford
Copy link

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
@tcrayford
Copy link
Author

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

@nrocy
Copy link
Collaborator

nrocy commented Jun 1, 2011

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

@ghost ghost assigned nrocy Jun 1, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants