Overloads for "..." exist with these types of results: ClosedRange <Bound>, CountableClosedRange <Bound>
Swift 2
let gap = CGFloat(randomInRange(StackGapMinWidth...maxGap)) Missing label for argument "range:" in call
Swift 3 - new bug
let gap = CGFloat(randomInRange(range: StackGapMinWidth...maxGap)) No candidates "..." create the expected context result type "Range"
Overloads for '...' exist with these types of results: ClosedRange, CountableClosedRange
+5
1 answer
With Swift 3, ..< and ... different ranges are produced:
..<creates aRange(orCountableRange, depending on the base type), which describes a half-open range that does not include an upper bound....creates aClosedRange(orCountableClosedRange) that describes a closed range that includes an upper bound.
If randomInRange() calculates a random number in a given range, including the upper bound, then it should be defined as
func randomInRange(range: ClosedRange<Int>) -> Int { // ... } and you can call him
let lo = 1 let hi = 10 let r = randomInRange(range: lo ... hi) +7