Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9320241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:35:15+00:00 2026-06-19T03:35:15+00:00

Throughout my (short) career so far in programming (merely a student working on internship)

  • 0

Throughout my (short) career so far in programming (merely a student working on internship) I have noticed that when it comes to IF statements, there is two different ways of doing it.

If we take foo as a boolean value:

if(foo)
{
    //do stuff
}

This is my preferred way of doing things when dealing with IF statements, if I’m looking for false I use:

if(!foo)
{
    //do more stuff
}

However, when some people see this they raise an eyebrow, suggesting that I may be stuck in a bad habit. But I wanted to know, is there any difference between this way or the “typical” way?

if(foo == true)
{
    //do a bit more stuff
}

Am I falling into a common trap for new programmers? Or is there no difference (at least a noticeable one)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T03:35:16+00:00Added an answer on June 19, 2026 at 3:35 am

    I never write == true or == false. It goes against the point of an if-sentence, in my opinion.

    an if is basicly: If a Boolean expression is true, do something. a Boolean is a boolean expression in and of itself, so why wrap it?

    So in my opinion, the ones using == true are the ones with a bad habit. Becuase they display ignorance of how the language works.

    think of these “allowed” ways to write if (Foo) and if (!Foo):

    if (Foo == true) //If Foo is the same as true
    if (Foo != true //If Foo is not the same as true
    if (Foo != false) //if Foo is not the same as false
    if (Foo == false) //If Foo is the same as false
    if (Foo) //If Foo
    if (!Foo) //If not Foo
    

    using == and != with booleans actually introduce new ways to make mistakes both when programming and reading code.

    Boolean and !Boolean is hard to misread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Throughout a Bison grammar I am using right recursion, and I have read that
I have 10 checkboxes that are scattered throughout a page and if any one
I have a subclass of ListActivity that is reused throughout my project, subclassed again
I am college student (computer science) and have just started a C# programming class.
I have an abstract class that defines basic behavior for socially used objects throughout
Short of diligently commenting out the numerous Log.v() and Log.d() statements I planted throughout
In the UK throughout the 80's and 90's (70's too I believe!) there was
As discussed throughout the various MVC questions and blogposts , we know that the
I have a form split apart throughout 4 tabs. One of the tabs contains
Lets say I have multiple DataGrids throughout my winform app and I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.