初級 › end忘れによる SyntaxError の原因と直し方 › パターン4
end忘れによる SyntaxError の原因と直し方
def・if・class・while などのブロックはすべて end で閉じる必要があります。
1 i = 0 2 while i < 3 3 puts i 4 i += 1 5 ____ ^ 6 7 puts "finished"
main.rb:7: syntax error, unexpected end-of-input, expecting `end' or dummy end (SyntaxError)
puts "finished"
^
空欄を埋めて実行を通す
whileループもendで閉じます。ループ本体が1行でも省略はできません。
次の問題