Discussion 解説
If the collection is empty, the value of this property is nil
.
コレクションが空であるならば、このプロパティはnil
です。
let numbers = [10, 20, 30, 40, 50]
if let firstNumber = numbers.first {
print(firstNumber)
}
// Prints "10"
Availability
Technology
var first: Base.Element
? { get }
Base
conforms to Collection
.
Base
がCollection
に準拠する時に利用可能です。
If the collection is empty, the value of this property is nil
.
コレクションが空であるならば、このプロパティはnil
です。
let numbers = [10, 20, 30, 40, 50]
if let firstNumber = numbers.first {
print(firstNumber)
}
// Prints "10"