小编ben*_*127的帖子

如何在Swift中的Bools数组中找到许多True语句

我是一个新开发人员,似乎无法弄清楚如何在布尔数组中找到True语句的数量.我知道如何通过索引而不是通过值来查找.任何援助将不胜感激.

let arrayElement = [Bool](repeating: false, count: 10)
var before: [[Bool]] = [[Bool]](repeating: arrayElement, count:10)
for i in 0 ..< 10 {
    for j in 0 ..< 10 {
        if arc4random_uniform(3) == 1 {
            before[i][j] = true  
        }        
    }
}
Run Code Online (Sandbox Code Playgroud)

arrays boolean swift

8
推荐指数
1
解决办法
1975
查看次数

标签 统计

arrays ×1

boolean ×1

swift ×1