24
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rubocop様に"Use next to skip iteration."のご指導を頂いたら。。。

Last updated at Posted at 2014-09-11

普通にeachしてifしたら、rubocop様から"Use next to skip iteration."とのご指導を頂いた。

items.each do |item|
  if item
    # my stuff with item
  end
end

どうもrubocop様は、each内のif..endよりnextでのguard clauseがお気に入りのようである。
下記のように修正したら喜んで頂いた。

items.each do |item|
  next unless item
  # my stuff with item
end

独り言

javaエンジニアの常識がrubyでは非常識ですね。ご指導、ありがとうございました!

24
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?