Open scepticalcat opened 3 years ago
Yes for simple formats Regex could be used but in case the format changed to a particularly complex one then RegEx - are error prone - and for tricky situation the regex can take forever to resolve.
When it comes to input command I prefer to fail and someone look into it. Worth the investment of time.
https://github.com/KarthickNarayana/toy_robot/blob/3d570a92d5c8b027e2456ec4f7bce47223719ecf/lib/toy_robot/command.rb#L5
The
case
statement here is unnecessarily onerous. If the signature of any of the commands were to change then case conditions would also need to be updated. While it does catch invalid commands, this could be done in other ways and this entire method could be simplified with a smartly written regex.