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 8193639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:32:36+00:00 2026-06-07T04:32:36+00:00

Possible Duplicate: Boolean types There are times when you want to conditionally set a

  • 0

Possible Duplicate:
Boolean types

There are times when you want to conditionally set a bool to true or false, but otherwise just to leave it alone. But many times, you do want to set it to either true or false, based on the state of this and/or that. I’ve often wondered why, in this latter case, most people seem to write code like this (even in books):

if ((location < Platypi.Length) && (Platypi[location] != null))
{
  return true;
}
else
{
  return false;
}

When this would be just as clear and more concise:

return ((location < Platypi.Length) && (Platypi[location] != null));

Is being verbose really the preferred method? To me, it borders on being a code smell.

  • 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-07T04:32:39+00:00Added an answer on June 7, 2026 at 4:32 am

    No, there is no reason to do that except to make the flow of the code explicitly clear. Personally, I would write it as:

    return location < Platypi.Length && Platypi[location] != null;
    

    though, because I find it just as easy to understand as the expanded version. Some people might get thrown off by it, though.

    Or, it could just be a mistake people make occasionally.

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

Sidebar

Related Questions

Possible Duplicate: What is the difference between Bool and Boolean types in C# I'm
Possible Duplicate: Why boolean in Java takes only true or false? Why not 1
Possible Duplicate: What is the difference between Bool and Boolean types in C# What
Possible Duplicate: Is there a way in MySQL to reverse a Boolean field with
Possible Duplicate: Cannot set boolean values in LocalStorage? So i've been trying to get
Possible Duplicate: Null vs. False vs. 0 How does php cast boolean variables? I
Possible Duplicate: Is short-circuiting boolean operators mandated in C/C++? And evaluation order? Is there
Possible Duplicate: How can I convert a string to boolean in JavaScript? I have
Possible Duplicate: Fast way to convert a Bitmap into a Boolean array in C#?
Possible Duplicate: mysql_fetch_array() expects parameter 1 to be resource, boolean given in select This

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.