Handy use of extension method on a bool

I don’t like to overuse if/else statements. I really dislike seeing code like this:

I just had an idea about using extension methods so I can write this instead:

and here’s the extension method:

Nice or not? I think it reads a bit better (for single line expressions anyway).

🙏🙏🙏

Since you've made it this far, sharing this article on your favorite social media network would be highly appreciated 💖! For feedback, please ping me on Twitter.

Published