threerings/aspirin — comment on commit 7d338ef37d8de4883dfa0bd748781ef6935998b7
File:  line 0
By jamie-threerings:

On 10/14/2011 03:03 PM, Ray Greenwell wrote:
> Guava's Predicates class lets you pass in 0 Predicates to and() and or().
>
> That seems reasonable to me.
>
> Let's say you're filtering something based on predicates, according to some externally-supplied data:
>
> List preds = Lists.newArrayList();
> if (userData.filterDeadBeatDads) {
> preds.add(MyPredicates.NO_DEADBEATS);
> }
> if (userData.filterAlaskans) {
> preds.add(MyPredicates.NO_ALASKANS);
> }
> // etc...
>
> List records = Lists.newArrayList(Iterables.filter(source, Predicates.and(preds)));
>
> This does what you'd expect it to do.
> Otherwise, at the end you'd have to manually check to see that your predicates are empty and either not filter or pass a Predicates.alwaysTrue() instead of your anded predicates.
>

Oh, I'm actually just guaranteeing that the functions themselves take at
least one argument, something java does for you. In actionscript, it is
almost always a bug to do that and otherwise must be worked around at
the call site.