【发布时间】:2010-12-08 17:29:20
【问题描述】:
如果列表中的所有项目都具有相同的值,那么我需要使用该值,否则我需要使用“otherValue”。我想不出一个简单明了的方法来做到这一点。当列表为空时,它应该返回“其他”值。
另见Neat way to write loop that has special logic for the first item in a collection.
【问题讨论】:
-
在你相当厚颜无耻的注意力吸引者上,我会选择 Ani 的回答 stackoverflow.com/questions/4390232/…