The first element of the collection.
SDK
- Xcode 11.0+
Framework
- Swift Standard Library
Declaration
var first: CollectionDifference <ChangeElement>.Change? { 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"