all any 或 此运算符后面必须跟,NSPredicate中ALL,ANY和SOME运算符之间的区别

I'm really struggling to understand these 3. It looks like ANY and SOME do the same thing, but I don't see the difference with ALL.

解决方案

Let's have a list of groups. Every group has members of type person. Every person has an age.

ALL members.age > 30

means that you will find a group with members that are all older than 30. You will not find a group with at least one single member being 30 or younger.

ANY members.age > 30

means that you will find a group with at least one member older than 30. You will not find a group with all members being 30 or younger.

Group1 > 30

Amin 45 YES

Chris 29 NO

---

All NO (because Chris is too young)

Any YES (because Amin is old enough)

Group2 > 30

Amin 45 YES

Foo 35 YES

---

All YES (because all members are old enough)

Any YES (because at least one member is old enough)

Group3 > 30

Chris 29 NO

Bar 21 NO

---

All NO (because at least one member is too young)

Any NO (because all members are too young)

With the ALL predicate you find Group2, because all members (Amin, Foo) matches the predicate. With the ANY predicate you will find both groups, because in both groups at least one member matches the predicate.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值