I have a list of logical elements:
def list=[true,false,true,true]
I ask if a method exists, for example the following:
list.joinBoolean('&&')
<false
Because: true && false && true && true = false
list.joinBoolean('||')
<true
Because: true || false || true || true = true
if it does not exist, I know how to make a loop to get the expected result;
AND
boolean tmp=true; list.each{e-> tmp=tmp && e; } return tmp;
OR
boolean tmp=false; list.each{e-> tmp=tmp || e; } return tmp;
source share