Now, we want to be able to use any of the integer types as types in our MutableVector3D<T>
and ImmutableVector3D<T>
classes. We just need to extend the desired types to make them conform to the previously created NumericForVector
protocol.
We want to make the two classes capable of working with elements of any integer type supported in Swift—that is, any of the following types:
Int
Int16
Int32
Int64
Int8
UInt
UInt16
UInt32
UInt64
UInt8
The following lines extend the previously enumerated types to conform to the NumericForVector
protocol:
// Signed integers extension Int: NumericForVector { } extension UInt: NumericForVector { } extension Int16: NumericForVector { } extension Int32: NumericForVector { } extension Int64: NumericForVector { } extension Int8: NumericForVector { } // Unsigned integers extension UInt16: NumericForVector { } extension UInt32: NumericForVector { } extension UInt64: NumericForVector { } extension...