如何检查所有列表项是否具有相同的值并将其返回,或者如果没有,则返回"otherValue"? [英] How to check if all list items have the same value and return it, or return an “otherValue” if they don’t?
本文介绍了如何检查所有列表项是否具有相同的值并将其返回,或者如果没有,则返回"otherValue"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果列表中的所有项目都具有相同的值,那么我需要使用该值,否则需要使用"otherValue".我想不出一种简单明了的方法.
If all the items in a list have the same value, then I need to use that value, otherwise I need to use an "otherValue". I can’t think of a simple and clear way of doing this.
查看全文