最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]swift中的do while语法如何写

Swift crifan 2938浏览 0评论

想要实现:

        do {
            let curRandomNum = getRandomInRange(lower, upper: upper)
        }while(curRandomNum not in uniqueIntArr)
结果却提示了:
do-while statement is not allowed; use ‘repeat-while’ instead
- repeat {
    statements
- } while condition
[总结]
最后用:
repeat {
    curRandomNum = getRandomInRange(lower, upper: upper)
}while(uniqueRandomArr.contains(curRandomNum))

即可。

转载请注明:在路上 » [已解决]swift中的do while语法如何写

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
84 queries in 0.170 seconds, using 22.11MB memory