Test your knowledge

  1. When we declare protocols, the Self keyword signifies:
    1. The type that implements the protocol.
    2. The instance of a class that conforms to the protocol.
    3. The instance of a struct that conforms to the protocol.

  2. Generics allow us to declare a class that:
    1. Can use a generic type only as the type for stored and type properties.
    2. Can use a generic type only as an argument for its initializers.
    3. Can work with many generic types.

  3. The open class ImmutableVector3D<T: FloatingPoint> line means:
    1. The generic type constraint specifies that T must conform to the ImmutableVector3D protocol or belong to the ImmutableVector3D class hierarchy.
    2. The generic type constraint specifies that T must conform to the FloatingPoint protocol or belong to the FloatingPoint class hierarchy.
    3. The class is a subclass of FloatingPoint.

  4. The open class Party<T: AnimalProtocol> where T: Equatable line means:
    1. The generic type constraint specifies that T must conform to both the AnimalProtocol and Equatable protocols.
    2. The generic type constraint specifies that T must conform to either the AnimalProtocol or Equatable protocol.
    3. The class is a subclass of both the AnimalProtocol and Equatable classes.

  5. The associatedtype keyword followed by the desired name allows us to declare:
    1. The generic type constraints, which is equivalent to the where keyword.
    2. An associated type for a protocol.
    3. An alias name for the protocol name.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.21.108