Created
January 31, 2012 17:50
-
-
Save baileylo/1711831 to your computer and use it in GitHub Desktop.
Which would you rather see?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Which would you rather see | |
// Option 1 - double assignment | |
function isInCharge($name) { | |
$in_charge = false; | |
if ($name === 'Charles') { | |
$in_charge = true; | |
trigger_event('Play Charles In Charge theme song'); | |
} | |
return $in_charge; | |
} | |
// Option 2 - gdgt safe | |
function isInCharge($name) { | |
if ($name === 'Charles') { | |
$in_charge = true; | |
trigger_event('Play Charles In Charge theme song'); | |
} else { | |
$in_charage = false; | |
} | |
return $in_charge; | |
} | |
// Option 3 - Logan Safe | |
function isInCharge($name) { | |
if ($in_charge = ($name === 'Charles')) { | |
trigger_event('Play Charles In Charge theme song'); | |
} | |
return $in_charge; | |
} | |
// Option 4 - double evaluation | |
function isInCharge($name) { | |
$in_charge = ($name === 'Charles'); | |
if ($in_charge) { | |
trigger_event('Play Charles In Charge theme song'); | |
} | |
return $in_charge; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment