Operator 演算子

..<(_:)

Returns a partial range up to, but not including, its upper bound. それの上側の境界までの、しかしそれを含んでいない、部分的な範囲を返します。

Declaration 宣言

prefix static func ..< (maximum: Unicode.Scalar) -> PartialRangeUpTo<Unicode.Scalar>

Parameters パラメータ

maximum

The upper bound for the range. 範囲の上側の境界。

Discussion 解説

Use the prefix half-open range operator (prefix ..<) to create a partial range of any type that conforms to the Comparable protocol. This example creates a PartialRangeUpTo<Double> instance that includes any value less than 5.0. 前置半開範囲演算子(前置..<)を使うことで何らかの型の部分的な範囲でComparableプロトコルに準拠するものを作成してください。この例は、PartialRangeUpTo<Double>インスタンスで5.0より少ない何らかの値を含むものを作成します。


let upToFive = ..<5.0


upToFive.contains(3.14)       // true
upToFive.contains(6.28)       // false
upToFive.contains(5.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, but not including, the partial range’s upper bound. あなたは、あるコレクションのインデックスからなる、この型の部分的範囲を使うことで、コレクションの始まりからその部分的な範囲の上側の境界までの、しかしそれを含んでいない範囲を表すことができます。


let numbers = [10, 20, 30, 40, 50, 60, 70]
print(numbers[..<3])
// Prints "[10, 20, 30]"

Precondition: maximum must compare equal to itself (i.e. cannot be NaN). 前提条件:maximumはそれ自身と等しいと比較されなければなりません(すなわちNaNであることはできません)。

See Also 参照

Creating Ranges of Scalars スカラーの範囲を作成する