Contents

base

The underlying collection of the slice.

Declaration

var base: Base { get }

Discussion

You can use a slice’s base property to access its base collection. The following example declares singleDigits, a range of single digit integers, and then drops the first element to create a slice of that range, singleNonZeroDigits. The base property of the slice is equal to singleDigits.

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"