scala> val l = List()
l: List[Nothing] = List()
scala> l.forall(x=>false)
res0: Boolean = true
scala> l.forall(x=>true)
res1: Boolean = true
scala> l.exists(x=>false)
res2: Boolean = false
scala> l.exists(x=>true)
res3: Boolean = false
For above 2 predicate, now that no element exists in the list, how come forall return true? I am confused. could you somebody help explain?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…