In CF 10 (or Railo 4) this can be done more elegantly using cfscript and the Underscore.cfc library :
_ = new Underscore(); myCart = duplicate(session.myCart); accPresent = _.any(myCart, function(val) { return val.accs; }); prodPresent = _.any(myCart, function(val) { return !val.accs; }); bothPresent = accPresent && prodPresent;
The great thing about _.find () is that it stops as soon as the iterator function returns true, so you don't have to iterate over each element in the array.
Note. Using duplcate () is recommended when accessing shared-area variables to prevent deadlocks.
(Disclaimer: I wrote Underscore.cfc)
source share