---
title: "Discussion on \"Code Smell 101 - Comparison Against Booleans\" | Hashnode"
description: "Discussion on \"Code Smell 101 - Comparison Against Booleans\". When comparing to booleans, we perform magic castings and get unexpected results.\n\nTL;DR: Don't compare against true. Either you are true, or false or you shouldn't compare\n\nProblems\n\nHidden castings\n\nThe least surprise principle violation.\n\nFail Fas..."
url: "https://hashnode.com/posts/code-smell-101-comparison-against-booleans/618d0d19468c06249afc7c37"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Code Smell 101 - Comparison Against Booleans](https://maximilianocontieri.com/code-smell-101-comparison-against-booleans?utm_source=hashnode&utm_medium=feed)

When comparing to booleans, we perform magic castings and get unexpected results. TL;DR: Don't compare against true. Either you are true, or false or you shouldn't compare Problems Hidden castings The least surprise principle violation. Fail Fas...

Nov 11, 2021 · 2 min read · maximilianocontieri.com  
Read the article

-   [#programming](https://hashnode.com/tag/programming)
-   [#code-smell-1](https://hashnode.com/tag/code-smell-1)
-   [#clean-code](https://hashnode.com/tag/clean-code)
-   [#refactoring](https://hashnode.com/tag/refactoring)
-   [#programming-blogs](https://hashnode.com/tag/programming-blogs)

## Written by

[Maxi Contieri](https://hashnode.com/@mcsee)

@mcsee · Buenos Aires

  
[View profile](https://hashnode.com/@mcsee)

Software Engineer

I’m a senior software engineer loving clean code, and declarative designs. S.O.L.I.D. and agile methodologies fan.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
