Generic Instance Method

relative(to:)

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

Declaration

func relative<C>(to collection: C) -> Range<Bound> where Bound == C.Index, C : Collection

Parameters

collection

The collection to evaluate this range expression in relation to.

Return Value

A range suitable for slicing collection. The returned range is not guaranteed to be inside the bounds of collection. Callers should apply the same preconditions to the return value as they would to a range provided directly by the user.

Relationships

From Protocol

See Also

Converting Ranges

init(ClosedRange<Bound>)

Creates an instance equivalent to the given ClosedRange.

init?(NSRange, in: String)