0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

rubyでeachメソッドで空配列をループで回しても処理は走らない

Last updated at Posted at 2024-09-28

当たり前の話だけどeachメソッドでループ回す際に、要素がないとループ処理は走らない。

def hoge
  [].each do |i|
    p i
  end
end

hoge
p "fuga" # fuga

なので、eachの中で要素がない場合はどうなる?のテストは不要

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?