Skip to content

Instantly share code, notes, and snippets.

@sophistifunk
Created May 19, 2011 02:09
Show Gist options
  • Save sophistifunk/980033 to your computer and use it in GitHub Desktop.
Save sophistifunk/980033 to your computer and use it in GitHub Desktop.
Find:In:Having:Of:
package intelligentpathways.utils
{
/**
* Search a collection, returning the object where object[fieldName] == value. Because I'm sick of writing this ugly loop for every combobox in a system :(
*/
public function findInHavingOf(collection:*, fieldName:String, value:*):*
{
for each (var testee:* in collection)
if (testee && fieldName in testee && testee[fieldName] == value)
return testee;
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment