Error[8]: Undefined offset: 4, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述任何人都知道一种优雅的方法来返回值为true的Bools数组中的索引值数组.例如: let boolArray = [true, true, false, true] 这应该返回: [0,1,3] let boolArray = [true, true, false, true]let trueIdxs = boolArray.enumerate().flatMap { $1 ? $0 : ni 任何人都知道一种优雅的方法来返回值为true的Bools数组中的索引值数组.例如:

let boolArray = [true,true,false,true]

这应该返回:

[0,1,3]
解决方法
let boolArray = [true,true]let trueIDxs = boolArray.enumerate().flatMap {  ? 
let boolArray = [true,true]let trueIDxs = boolArray.enumerate().filter {  }.map { [+++].0 }print(trueIDxs) // [0,3]
: nil }print(trueIDxs) // [0,3]

或者(可能更具可读性)

[+++] 总结

以上是内存溢出为你收集整理的arrays – 从Bool数组返回索引值数组,其中为true全部内容,希望文章能够帮你解决arrays – 从Bool数组返回索引值数组,其中为true所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 5, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述任何人都知道一种优雅的方法来返回值为true的Bools数组中的索引值数组.例如: let boolArray = [true, true, false, true] 这应该返回: [0,1,3] let boolArray = [true, true, false, true]let trueIdxs = boolArray.enumerate().flatMap { $1 ? $0 : ni 任何人都知道一种优雅的方法来返回值为true的Bools数组中的索引值数组.例如:

let boolArray = [true,true,false,true]

这应该返回:

[0,1,3]
解决方法
let boolArray = [true,true]let trueIDxs = boolArray.enumerate().flatMap {  ? 
let boolArray = [true,true]let trueIDxs = boolArray.enumerate().filter {  }.map { .0 }print(trueIDxs) // [0,3]
: nil }print(trueIDxs) // [0,3]

或者(可能更具可读性)

[+++] 总结

以上是内存溢出为你收集整理的arrays – 从Bool数组返回索引值数组,其中为true全部内容,希望文章能够帮你解决arrays – 从Bool数组返回索引值数组,其中为true所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
arrays – 从Bool数组返回索引值数组,其中为true_app_内存溢出

arrays – 从Bool数组返回索引值数组,其中为true

arrays – 从Bool数组返回索引值数组,其中为true,第1张

概述任何人都知道一种优雅的方法来返回值为true的Bools数组中的索引值数组.例如: let boolArray = [true, true, false, true] 这应该返回: [0,1,3] let boolArray = [true, true, false, true]let trueIdxs = boolArray.enumerate().flatMap { $1 ? $0 : ni 任何人都知道一种优雅的方法来返回值为true的Bools数组中的索引值数组.例如:

let boolArray = [true,true,false,true]

这应该返回:

[0,1,3]
解决方法
let boolArray = [true,true]let trueIDxs = boolArray.enumerate().flatMap {  ? 
let boolArray = [true,true]let trueIDxs = boolArray.enumerate().filter {  }.map { .0 }print(trueIDxs) // [0,3]
: nil }print(trueIDxs) // [0,3]

或者(可能更具可读性)

总结

以上是内存溢出为你收集整理的arrays – 从Bool数组返回索引值数组,其中为true全部内容,希望文章能够帮你解决arrays – 从Bool数组返回索引值数组,其中为true所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1008064.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存