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

WhileUntil complains when alternative is not legal Ruby #664

Closed
agrimm opened this issue Dec 10, 2013 · 0 comments
Closed

WhileUntil complains when alternative is not legal Ruby #664

agrimm opened this issue Dec 10, 2013 · 0 comments

Comments

@agrimm
Copy link
Contributor

agrimm commented Dec 10, 2013

The following code will cause the WhileUntil cop to complain.

lines = %w{first second third}

while (line = lines.shift)
  puts line
end

However, the alternative is not legal Ruby. The following code

lines = ["first", "second", "third"]
puts line while (line = lines.shift)

would give the error message

-:2:in `<main>': undefined local variable or method `line' for main:Object (NameError)
bbatsov added a commit that referenced this issue Dec 17, 2013
[Fix #664] Accept oneline while when condition has local variable assignment
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

1 participant