从 Objective-C 中的 for 循环返回
我有一个带有计算机人工智能的游戏,它将信息保存到一个数组中,我需要循环遍历该数组,这很好,但一旦它找到我正在寻找的值,它就会继续搜索,通常这不会是一个问题,但数组可能会变得非常大,我希望在获得所需的值后能够简单地停止循环。
I have a game with a computer AI that saves info to an array and I need to loop through the array, which is fine but once it finds the value I'm looking for it keeps searching, normaly this would not be a problem but the arrays can get quite large and I'd prefer to be able to simply stop the loop once I have the values that I need.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
break
语句:这也适用于
(for ... in ...)
循环。Use the
break
statement:This also works in
(for ... in ...)
loops.