Swift Mapping for Sequences
Here is the definition of our FruitPlatter
sequence once more:
Slice
sequence<Fruit> FruitPlatter;
The Slice compiler generates the following definition for the FruitPlatter
sequence:
Swift
public typealias FruitPlatter = [Fruit]
As you can see, the sequence simply maps to a standard array, so you can use the sequence like any other array. For example:
Swift
// Make a small platter with one Apple and one Orange // let platter: FruitPlatter = [.Apple, .Orange]
There is a single exception to this mapping rule: a sequence of bytes maps to Foundation.Data
and not [UInt8]
:
Slice
sequence<byte> ByteSeq;
becomes:
Swift
public typealias ByteSeq = Foundation.Data