Skip to content

Instantly share code, notes, and snippets.

@1cg
Forked from anonymous/gist:1282522
Created October 13, 2011 01:36
function controlStuff(){
var listOfThings = loadThings()
for(thing in listOfThings.whereTypeIs(CanDoSomething)){
thing.doSomething()
}
}
// or just...
function controlStuff(){
var listOfThings = loadThings()
listOfThings.whereTypeIs(CanDoSomething)*.doSomething()
}
// w/ closures
function controlStuff(){
var listOfThings = loadThings()
listOfThings.whereTypeIs(CanDoSomething).each( \ e -> e.doSomething() )
}
interface CanDoSomething {
function doSomething()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment