LoginSignup
0
0

More than 5 years have passed since last update.

Rubyの配列を繰り返し処理で取り出す①

Last updated at Posted at 2018-09-24

Rubyの配列を繰り返し処理で取り出す

今まで配列の取り出し方はEachで行なっていましたが、forでも同様の処理ができるのでメモ。

Eachで取り出す

sample.rb
arrays = ["hoge", "huga"]
arrays.each do |array|
   puts array
end

Forで取りだす

sample.rb
arrays = ["hoge", "huga"]
for array in arrays
   puts array
end

出力結果は同じです。

0
0
3

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