So I said, narrow the focus.
Your "use case" should be, there's a 22 year old college student
living in the dorms.
How will this software get him laid? - jwz
Being a Scheme guy I’ve always thought Closures to be a vital part of programming. I guess they weren’t considered a big deal by James Gosling as he famously didn’t include them in Java (though you can do a hack and they are coming in latest Java).
ActionScript3 on the other hand, which normally stands naked except for a rather flimsy bedsheet painted with the words I AM JAVA, does have closures. So I could do this today:
// Is the time in d greater than now - the seconds?
private function isTimeGreater(d:Date, seconds:int):Boolean {
var t:Date = new Date();
t.setTime(t.getTime() - seconds);
return d.valueOf() > t.valueOf()
}
// Makes a function that limits an array to a number of mins
private function withinFunc(limitMins:int):Function {
return function(obj:*, index:int, array:Array):Boolean {
return isTimeGreater(obj, 1000 * 60 * limitMins);
};
}
// ... some time later ... use the function
var newest:Array = report_so.data.report.filter(withinFunc(limitScanMins));
Credit where credit’s due, I say. And this is nifty. It makes the whole thing just a little more bearable. More like sticking pins in my ears, as opposed to my eyes.