Skip to content

Instantly share code, notes, and snippets.

@alecmce
Created July 18, 2011 09:02
Show Gist options
  • Save alecmce/1088960 to your computer and use it in GitHub Desktop.
Save alecmce/1088960 to your computer and use it in GitHub Desktop.
one return per method
// a difference is not a difference unless it *makes* a difference
public function add(item:*):Boolean
{
if (contains(item))
return false;
push(item);
return true;
}
public function add(item:*):Boolean
{
var notContained:Boolean = !contains(item);
if (notContained)
push(item);
return notContained;
}
@robertpenner
Copy link

I'm with squeedee. Guard clauses rule; conditional slaloms drool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment