Initializer

init(_:)

Creates an instance equivalent to the given Range.

Declaration

init(_ other: Range<Bound>)
Available when Bound conforms to Strideable and Bound.Stride conforms to SignedInteger.

Parameters

other

A Range to convert to a ClosedRange instance.

Discussion

An equivalent range must be representable as a closed range. For example, passing an empty range as other triggers a runtime error, because an empty range cannot be represented by a closed range instance.

See Also

Converting Ranges

func relative<C>(to: C) -> Range<Bound>

Returns the range of indices described by this range expression within the given collection.