Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. if bool

if bool

Scheduled Pinned Locked Moved The Weird and The Wonderful
13 Posts 13 Posters 150 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    innominate
    wrote on last edited by
    #1

    who else sees this and just laughs: if (whatever == true){ chkBox.Checked = true; }else{ chkBox.Checked = false; }

    M RaviBeeR K L R 7 Replies Last reply
    0
    • I innominate

      who else sees this and just laughs: if (whatever == true){ chkBox.Checked = true; }else{ chkBox.Checked = false; }

      M Offline
      M Offline
      Marcus J Smith
      wrote on last edited by
      #2

      In opposition to my own statement below I would probably do the following in this case.

      CallUpdateFunction(chBox.Checked)

      :-D


      CleaKO

      "I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy
      "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)

      1 Reply Last reply
      0
      • I innominate

        who else sees this and just laughs: if (whatever == true){ chkBox.Checked = true; }else{ chkBox.Checked = false; }

        RaviBeeR Offline
        RaviBeeR Offline
        RaviBee
        wrote on last edited by
        #3

        if (whatever == true) {
        chkBox.Checked = true;
        } else {
        chkBox.Checked = false;
        } else {
        ...
        }

        :) /ravi

        This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

        1 Reply Last reply
        0
        • I innominate

          who else sees this and just laughs: if (whatever == true){ chkBox.Checked = true; }else{ chkBox.Checked = false; }

          K Offline
          K Offline
          Kevin McFarlane
          wrote on last edited by
          #4

          This was discussed in an earlier thread.

          Kevin

          P 1 Reply Last reply
          0
          • K Kevin McFarlane

            This was discussed in an earlier thread.

            Kevin

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            Well, this takes that a step farther; not just the test, but the setting of another boolean. Every once in a while I catch myself doing that and I have to slap my hand.

            1 Reply Last reply
            0
            • I innominate

              who else sees this and just laughs: if (whatever == true){ chkBox.Checked = true; }else{ chkBox.Checked = false; }

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Its junk.

              chkBox.Checked = whatever;

              █▒▒▒▒▒██▒█▒██ █▒█████▒▒▒▒▒█ █▒██████▒█▒██ █▒█████▒▒▒▒▒█ █▒▒▒▒▒██▒█▒██

              T E 2 Replies Last reply
              0
              • L Lost User

                Its junk.

                chkBox.Checked = whatever;

                █▒▒▒▒▒██▒█▒██ █▒█████▒▒▒▒▒█ █▒██████▒█▒██ █▒█████▒▒▒▒▒█ █▒▒▒▒▒██▒█▒██

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #7

                Captain See Sharp wrote:

                chkBox.Checked = whatever;

                yeap you right.. you giving variable some unknown garbage value by doing so!

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                cheers, Alok Gupta Global Interface Table: An Easy Way to Marshal an Interface Pointer[new] VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                1 Reply Last reply
                0
                • I innominate

                  who else sees this and just laughs: if (whatever == true){ chkBox.Checked = true; }else{ chkBox.Checked = false; }

                  R Offline
                  R Offline
                  Russell Jones
                  wrote on last edited by
                  #8

                  I see it all the time. have also found this before chkBox.Checked = !(whatever == true); I think(hope) that these are normally incremental errors where the code has been tweaked bit by bit over the course of years. Boolean logic always seems to have people a bit stumped though and i'm never sure why. I've seen a few things like these in the past if (whatever || true) doStuff(); if (whatever && false) doStuff(); Russ

                  D J 2 Replies Last reply
                  0
                  • I innominate

                    who else sees this and just laughs: if (whatever == true){ chkBox.Checked = true; }else{ chkBox.Checked = false; }

                    B Offline
                    B Offline
                    Bradml
                    wrote on last edited by
                    #9

                    This is bad practice unless the language automatically converts between variable types. If that is the case then you could essentially assign any value to the object if you aren't careful.


                    Brad Australian - Bradml on "MVP Status" If this was posted in a programming board please rate my answer

                    1 Reply Last reply
                    0
                    • I innominate

                      who else sees this and just laughs: if (whatever == true){ chkBox.Checked = true; }else{ chkBox.Checked = false; }

                      E Offline
                      E Offline
                      Ed Poore
                      wrote on last edited by
                      #10

                      innominate wrote:

                      and just laughs:

                      No, I cringe

                      1 Reply Last reply
                      0
                      • R Russell Jones

                        I see it all the time. have also found this before chkBox.Checked = !(whatever == true); I think(hope) that these are normally incremental errors where the code has been tweaked bit by bit over the course of years. Boolean logic always seems to have people a bit stumped though and i'm never sure why. I've seen a few things like these in the past if (whatever || true) doStuff(); if (whatever && false) doStuff(); Russ

                        D Offline
                        D Offline
                        Dan Neely
                        wrote on last edited by
                        #11

                        I'll admit to occasionally ending up with something like this after hacking out part of a complex conditional or breaking it into several smaller lines, and not doing a sanity check with the remaining chunks.

                        -- Rules of thumb should not be taken for the whole hand.

                        1 Reply Last reply
                        0
                        • L Lost User

                          Its junk.

                          chkBox.Checked = whatever;

                          █▒▒▒▒▒██▒█▒██ █▒█████▒▒▒▒▒█ █▒██████▒█▒██ █▒█████▒▒▒▒▒█ █▒▒▒▒▒██▒█▒██

                          E Offline
                          E Offline
                          eugene genis
                          wrote on last edited by
                          #12

                          i agree - i would aslo have used this

                          1 Reply Last reply
                          0
                          • R Russell Jones

                            I see it all the time. have also found this before chkBox.Checked = !(whatever == true); I think(hope) that these are normally incremental errors where the code has been tweaked bit by bit over the course of years. Boolean logic always seems to have people a bit stumped though and i'm never sure why. I've seen a few things like these in the past if (whatever || true) doStuff(); if (whatever && false) doStuff(); Russ

                            J Offline
                            J Offline
                            Jorgen Sigvardsson
                            wrote on last edited by
                            #13

                            I do that all the time when I debug and test extreme cases which are hard to simulate using input. I wouldn't want to be caught forgetting about them though. :)

                            -- For proper viewing, take red pill now

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups