gpt4 book ai didi

groovy - 加入 bool 元素列表groovy

转载 作者:行者123 更新时间:2023-12-04 14:14:06 24 4
gpt4 key购买 nike

我有一个 bool 元素列表:

  def list=[true,false,true,true]

我问是否存在如下方法:
  list.joinBoolean('&&')

< 假

因为: true && false && true && true=false
list.joinBoolean('||')

< 真

因为:真||假||真||真=真

如果它不存在,我知道如何进行循环以获得预期结果;


  boolean tmp=true;
list.each{e->
tmp=tmp && e;
}
return tmp;


  boolean tmp=false;
list.each{e->
tmp=tmp || e;
}
return tmp;

最佳答案

anyevery方法可以在这里派上用场

关于groovy - 加入 bool 元素列表groovy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18380667/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com