Instance Property

first

The first element of the collection.

Declaration

var first: UInt8? { get }

Discussion

If the collection is empty, the value of this property is nil.

let numbers = [10, 20, 30, 40, 50]
if let firstNumber = numbers.first {
    print(firstNumber)
}
// Prints "10"

See Also

Getting Information About the Buffer

var isEmpty: Bool

A Boolean value indicating whether the collection is empty.

var last: UInt8?

The last element of the collection.

var underestimatedCount: Int

A value less than or equal to the number of elements in the collection.

func max() -> UInt8?

Returns the maximum element in the sequence.

func max(by: (UInt8, UInt8) -> Bool) -> UInt8?

Returns the maximum element in the sequence, using the given predicate as the comparison between elements.

func min() -> UInt8?

Returns the minimum element in the sequence.

func min(by: (UInt8, UInt8) -> Bool) -> UInt8?

Returns the minimum element in the sequence, using the given predicate as the comparison between elements.

func distance(from: Int, to: Int) -> Int

Returns the distance between two indexes.

func allSatisfy((UInt8) -> Bool) -> Bool

Returns a Boolean value indicating whether every element of a sequence satisfies a given predicate.