Discussion 解説
You can use a slice’s base
property to access its base collection. The following example declares single
, a range of single digit integers, and then drops the first element to create a slice of that range, single
. The base
property of the slice is equal to single
.
あなたはスライスのもつbase
プロパティを使って、それの基盤コレクションにアクセスできます。以下の例は、1桁整数からなる範囲、single
を宣言します、それから最初の要素を落としてその範囲のあるスライス、single
を作成します。このスライスのbase
プロパティは、single
に等しいです。
let singleDigits = 0..<10
let singleNonZeroDigits = singleDigits.dropFirst()
// singleNonZeroDigits is a Slice<Range<Int>>
print(singleNonZeroDigits.count)
// Prints "9"
print(singleNonZeroDigits.base.count)
// Prints "10"
print(singleDigits == singleNonZeroDigits.base)
// Prints "true"