Disney Count support may be spotty from here. We apologize for the inconvenience.

It's too simple to be awarded full marks. Expand it

/**
* @return true | false
* @param $val bool The bool to invert
* @desc Returns the
*/
function invert_bool($val){
if($val == true)
  return false;
if($val == false)
  return true;
}


Let's see how much we can earn "by the hour" by increasing the lines of code of the above example.
Permalink Vineet Reynolds 
January 10th, 2006
No.

Philo
Permalink Mark Warner 
January 10th, 2006
/**
* @return true | false
* @param $val bool The bool to invert
* @desc Returns the
*/
function invert_bool($val)
{
if($val == true)
  return false;
if($val == false)
  return true;
}
Permalink IanH. 
January 10th, 2006
So

return !($val);

wouldn't suffice then.
Permalink Simon Lucy 
January 10th, 2006
Congratulations, IanH., you win the contract.
Permalink PHB 
January 10th, 2006
/**
* @return true | false
* @param $val bool The bool to invert
* @desc Returns the
*/
function invert_bool($val){
if($val == true)
  return false;
if($val == false)
  return true;
}
____________
here's my one and only contribution to this exercise.

function invert_bool($val)
{
bool retVal = false;
if($val == true)
  retVal = false;
else
{
  if($val == false)
    retVal == true;
  else
    retVal == false;
}
return retVal;
}
Permalink Jacob 
January 10th, 2006
Right Simon,
One-liners are out of question.

I want documented answers [gnu style], with hyperlinks to describe every darn thing.

example answer:
try{
if($val.toString().equals(true))
{
return false;
}
else if($val.toString().notEquals(true))
{
return true
}
catch(Excception exObject)
{
print("THIS ERROR IS IMPOSSIBLE");
}
finally
{
__HALT;
}
Permalink Vineet Reynolds 
January 10th, 2006
This is roughly on-topic damn't.  Why do Indians continually want to program and/or talk about programming in the off-topic area? No wonder we outsource so much to your hard working bastards.
Permalink Phil 
January 10th, 2006
Amateurs!

/*
* @return true | false
* @param $val bool The bool to invert
* @desc Returns the inverse if the passed value
`* Expected values for $val:
*  true: True
*  false: False
*/

function invert_bool
(
$val  // Value to invert
)
{

/*
  * If the parameter is true...
  */
if
(
  $val == true
)
{
  /*
  * Return false
  */
  return false;
}

/*
  * If the parameter is false...
  */
if
(
  $val == false
)
{
  /*
  * Return true
  */
  return true;
}

/*
  * For all other values, assume it was false.
  */
return true; 

}
Permalink Mat Hall 
January 10th, 2006
DARN!!
This is off-topic. Let the infidel thread burn in hell.
Permalink Vineet Reynolds 
January 10th, 2006
I'm sorry, IanH., but upon further review, management has decided to award the contract to Mat.

Congratulations, Mat. Well-done, old man.
Permalink PHB 
January 10th, 2006
Sadly I've actually worked places where that's not too far from the standard -- all parameters to everything had to be on a line of their own, every conditional had to be commented with what you're testing (generally with an explanation of why), and everything had 12 or so lines of comments MINIMUM at the top with copyright notices, who wrote it, who revised it, when, why, and all sorts. It was enough to make me cry...
Permalink Mat Hall 
January 10th, 2006
Why not look here for your fun:

http://thedailywtf.com/forums/56201/ShowPost.aspx

Oh you got it from there.
Permalink O Canader 
January 11th, 2006

This topic was orginally posted to the off-topic forum of the
Joel on Software discussion board.

Other topics: January, 2006 Other topics: January, 2006 Recent topics Recent topics