I don’t know where you got that snippet from so I can’t tell if the surrounding code does something that depends on that line.
get has a side-effect where it throws an exception when the
key is null, and the map disallows null keys. If the surrounding code depends on this behavior in some way, then the line is relevant as an assertion.
However, in terms of a general solution to the problem, you’re right - I have no such line in my solution.