DEV Community

Discussion on: Guard Clauses

Collapse
 
entomy profile image
Patrick Kelly

Something I didn't mention, because to the best of my knowledge no guard clause library implements it yet, is that you can actually optimize the throwing of exceptions, and the mechanism for doing so isn't super obvious. It's only by a single instruction, and it's not worth doing in basically any scenario. However, a library who's job it is to literally do this kind of stuff, could be doing it. That's technically an advantage over manually written guards, and something I plan to implement eventually. Right now my hands are elsewhere.