判断是否为全部false

2022-09-08  本文已影响0人  奋斗的遗忘人
let arr = [false, true, false, false]
let passed = arr.allSatisfy({$0 == false})
 print("=====\(passed)")
打印结果
=====false

sorted 方法,闭包排序

 let names = [56, 38, 47, 29, 78, 76]
 let reversed = names.sorted(by:{$0 > $1})
 print("====\(reversed)")
====[78, 76, 56, 47, 38, 29]
上一篇下一篇

猜你喜欢

热点阅读