3 ms·
Nice, your example is cleaner than mine for sure. My example was copied from some code I'd written but looking at it again it's more verbose than necessary. Re
by dbattaglia 6y ago
Nice, your example is cleaner than mine for sure. My example was copied from some code I'd written but looking at it again it's more verbose than necessary.
Re: compile time vs runtime errors, it is a valid point. In Scala (which I use in my day job) I will generally question any use of `case _ =>` in a pattern match because of this, particularly because you don't get the nice compiler error when someone (for example) adds a new type to a sealed trait hierarchy without making sure all business logic that touches that type handles the new case correctly. I guess in C++ it feels painful for a non-expert like myself to get those types of compile time guarantees while functional languages like Scala (for example) make it easy.