[英]Type HalfOpenInterval<T> does not conform to protocol BooleanType
I have a very simple for loop that is giving me troubles. 我有一个非常简单的for循环,这给我带来了麻烦。 This code ran without issue in Xcode beta 4, but in beta 5 it is complaining that the half open interval (and the closed interval) don't conform to BooleanType.
这段代码在Xcode beta 4中运行没有问题,但是在beta 5中,它抱怨说半开间隔(和关闭间隔)不符合BooleanType。 What has changed, why doesn't this work anymore, or is this a bug?
发生了什么变化,为什么现在不起作用了,或者这是一个错误?
for let i = 0; i..<cellCount!; ++i {
//do stuff
}
cellCount
is defined as an optional Int
property: cellCount
定义为可选的Int
属性:
private var cellCount: Int?
I have tried storing the cellCount into a non-optional constant but the issue still remains: 我尝试将cellCount存储到一个非可选常量中,但问题仍然存在:
let numberOfCells: Int = cellCount!
for let i = 0; i..<numberOfCells; ++i {
//do stuff
}
I see in the Release Notes a lot has changed with Ranges, but nothing seems to be relevant to this issue. 我在发行说明中看到Ranges发生了很多变化,但似乎与该问题无关。
Ranges are meant to be used in a for in
loop: 范围应在
for in
循环中使用:
for i in 0..<cellCount! {
// do stuff
}
Does this have anything to do with HalfOpenInterval? 这与HalfOpenInterval有关系吗? I thought the struct is Range?
我以为结构是范围? If you use HalfOpenInterval in for-in, it will not work.
如果在for-in中使用HalfOpenInterval,它将无法正常工作。 It is not of protocol SequenceType
它不是协议SequenceType
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.