简体   繁体   中英

Type HalfOpenInterval<T> does not conform to protocol BooleanType

I have a very simple for loop that is giving me troubles. 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. 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:

private var cellCount: Int?

I have tried storing the cellCount into a non-optional constant but the issue still remains:

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 are meant to be used in a for in loop:

for i in 0..<cellCount! {
    // do stuff
}

Does this have anything to do with HalfOpenInterval? I thought the struct is Range? If you use HalfOpenInterval in for-in, it will not work. It is not of protocol SequenceType

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM