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

Setで充分かつSetのほうが高速に動作しそうなArrayの使い方を見つけたら怒るCop #28

Open
pocke opened this issue Feb 21, 2020 · 0 comments

Comments

@pocke
Copy link
Owner

pocke commented Feb 21, 2020

型がなくてもできそう

def foo(ids)
  already_done_something_ids = []
  ids.each do |id|
    next if already_done_something_ids.include? id

    do_something id
  end
end

ここでalready_done_something_ids は Array よりも Set のほうが良さそう

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

No branches or pull requests

1 participant