初級 › end忘れによる SyntaxError の原因と直し方 › パターン2
end忘れによる SyntaxError の原因と直し方
def・if・class・while などのブロックはすべて end で閉じる必要があります。
1 score = 80 2 if score >= 60 3 puts "pass" 4 ____ ^ 5 6 puts "done"
main.rb:6: syntax error, unexpected end-of-input, expecting `end' or dummy end (SyntaxError)
puts "done"
^
空欄を埋めて実行を通す
if文もendで閉じます。中カッコを使わないRubyでは、endの有無だけがブロックの境界を示します。
次の問題