「Ruby」nextでループの処理をするサンプル

2020年12月19日

書式
配列名.each do |変数名|
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#!/usr/bin/ruby
# -*- coding: UTF-8 -*-
cftArr = [11, 22,33, 44, 55, 66, 77]
cftArr.each do |t|
next if t == 55
puts t
end
#!/usr/bin/ruby # -*- coding: UTF-8 -*- cftArr = [11, 22,33, 44, 55, 66, 77] cftArr.each do |t| next if t == 55 puts t end
#!/usr/bin/ruby
# -*- coding: UTF-8 -*-

cftArr = [11, 22,33, 44, 55, 66, 77]
cftArr.each do |t|
  next if t == 55
  puts  t
end

実行結果
>ruby test.rb
11
22
33
44
66
77

Ruby

Posted by arkgame