Skip to content

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

Description

@tom-pang

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions