continue
C や他の多くの言語には、ループ内で使用するとループの次の反復にジャンプするキーワードがあります。Rubycontinue
にはこのキーワードに相当するものはありますか?
ベストアンサー1
はい、 といいますnext
。
for i in 0..5
if i < 2
next
end
puts "Value of local variable is #{i}"
end
出力は次のようになります。
Value of local variable is 2
Value of local variable is 3
Value of local variable is 4
Value of local variable is 5
=> 0..5