想要实现:
do { let curRandomNum = getRandomInRange(lower, upper: upper) }while(curRandomNum not in uniqueIntArr)
结果却提示了:
do-while statement is not allowed; use ‘repeat-while’ instead |
[解决过程]
1.搜:
swift do while
参考:
语法是:
- repeat { statements - } while condition
[总结]
最后用:
repeat { curRandomNum = getRandomInRange(lower, upper: upper) }while(uniqueRandomArr.contains(curRandomNum))
即可。
转载请注明:在路上 » [已解决]swift中的do while语法如何写