IntervalType has been removed in Swift 3. Use ranges instead

I am trying to convert my swift 2.3 code into swift 3.0.

And at some point, I am getting error :

public struct Datum  
{  
    let moment:TimeInterval  
    let value:CGFloat  
}  

And here is my function :

private func isProperSeries<T:IntervalType>(_ series:[Datum], forWindow window:T) -> Bool where T.Bound == TimeInterval {  

     return isProperSeries(series, forWindowStart: window.start, end: window.end)  
}  

another one is :

private func isProperSeries(_ series:[Datum], forWindowStart start:TimeInterval, end:TimeInterval) -> Bool {

    return series.index(where: {$0.moment == start }) != nil && series.index(where: {$0.moment == end }) != nil
}

I am getting error like :

’IntervalType’ is unavailable: IntervalType has been removed in Swift 3. Use ranges instead.

Please help me to convert above code in swift 3.

I don’t know what your other isProperSeries function does. Without that, my best guess is this:

private extension Sequence where Iterator.Element == Datum {
	func isProperSeries(window: Range<TimeInterval>) -> Bool {
data.isProperSeries(window: 1..<2)
1 Like

Ole Begmann has written two blogs on this - one on Ranges and Intervals and a newer one deprecating it… all about Ranges.

1 Like

@jcatterwaul and @aeberbach Thanks for your answer.

I have edited my post, please check it. In that I have added another function.