Ruby 3.2 introduces the new feature syntax_suggest
, formerly known as the gem dead_end
, now integrated into Ruby. Catch and fix syntax errors are now more robust helping you to find the position of errors such as missing extra parentheses, commas, superfluous ends, errors such as missing or extra curly braces related to string interpolation, and semicolons.
Missing end
1
2
3
4
5
6
# Unmatched `end', missing keyword (`do', `def`, `if`, etc.) ?
class Car
defdrive
end
end
Missing keyword
1
2
3
4
5
6
7
8
# Unmatched `end', missing keyword (`do', `def`, `if`, etc.) ?
class Car
def drive
@directions.each |direction|
end
end
end
Missing pair characters (like {}, [], () , or | ) |
1
2
3
4
5
6
# Unmatched `(', missing `)' ?
class Drive
def drive(direction
end
end
To check your entire project, run the ‘ruby -cw’ command, and it will provide suggestions if any errors are detected.