Instance Subscriptswift 6.0.1Swift
subscript(_:)
Accesses the element at the specified position.
subscript(position: Int) -> Element { get set }
Parameters
- position
The position of the element to access. The only valid position in a
CollectionOfOne
instance is0
.
Other members in extension
Types
struct Iterator
An iterator that produces one or zero instances of an element.
Typealiases
Type members
init(Element
) Creates an instance containing just the given element.
Instance members
var count: Int
The number of elements in the collection, which is always one.
var customMirror: Mirror
var debugDescription: String
A textual representation of the collection, suitable for debugging.
var endIndex: CollectionOfOne<Element>.Index
The “past the end” position—that is, the position one greater than the last valid subscript argument.
var startIndex: CollectionOfOne<Element>.Index
The position of the first element.
subscript(Range<Int>
) -> CollectionOfOne<Element>.SubSequence func index(after: CollectionOfOne<Element>.Index
) -> CollectionOfOne<Element>.Index Returns the position immediately after the given index.
func index(before: CollectionOfOne<Element>.Index
) -> CollectionOfOne<Element>.Index Returns the position immediately before the given index.
func makeIterator(
) -> CollectionOfOne<Element>.Iterator Returns an iterator over the elements of this collection.