Posted By

kungfoo on 01/07/10


Tagged

bool


Versions (?)

Boolean Swap Method


 / Published in: Java
 

Pretty cool overstatement...

  1. protected boolean invertbool(boolean bool) {
  2. if (bool)
  3. return false;
  4. else
  5. return true;
  6. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: MMDeveloper on January 7, 2010

you could also just do this

function whatever(bool) { return !bool; }

the !bool should invert the boolean value. So you shouldn't even need a separate method/function to do this.

Posted By: kungfoo on May 20, 2010

This was intended to show the worst way to do it :D But thanks.

You need to login to post a comment.