Use the prefix closed range operator (prefix ...) to create a partial range of any type that conforms to the Comparable protocol. This example creates a PartialRangeThrough<Double> instance that includes any value less than or equal to 5.0.
前置完結範囲演算子(前置...)を使うことで何らかの型の部分的な範囲でComparableプロトコルに準拠するものを作成してください。この例は、PartialRangeThrough<Double>インスタンスで5.0より少ないか等しい何らかの値を含むものを作成します。
let throughFive =...5.0throughFive.contains(4.0) // truethroughFive.contains(5.0) // truethroughFive.contains(6.0) // false
You can use this type of partial range of a collection’s indices to represent the range from the start of the collection up to, and including, the partial range’s upper bound.
あなたは、あるコレクションのインデックスからなる、この型の部分的範囲を使うことで、コレクションの始まりからその部分的な範囲の上側の境界までの、そしてそれを含んでいる範囲を表すことができます。
let numbers = [10, 20, 30, 40, 50, 60, 70]print(numbers[...3])// Prints "[10, 20, 30, 40]"
Precondition: maximum must compare equal to itself (i.e. cannot be NaN).
前提条件:maximumはそれ自身と等しいと比較されなければなりません(すなわちNaNであることはできません)。