How to Short-Circuit a Sequence of Operations with a Boolean Value--Jonathan Boccara

Boolean and bit operators are not the same.

How to Short-Circuit a Sequence of Operations with a Boolean Value

by Jonathan Boccara

From the article:

Interrupting a sequence of operations when one of them fails is a common problem in computer programming. There are plenty of elaborate ways to code that, ranging from exceptions to monads to static exceptions.

One of the techniques to stop such a sequence of operations that is not so sophisticated, but that can be found in existing code, is to use a boolean. This relies on each step producing a boolean flag to indicate if it succeeded or failed, and to stop executing steps at the first failure.

However, simple as it is, this technique can lead to code that doesn’t do with it looks like...

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.