The following lines declare a
PartyError
enum that conforms to the ErrorType
protocol. This way, we will be able to throw a specific exception in the next class that we will create:
public enum PartyError: ErrorType {
case InsufficientMembersToRemoveLeader
case InsufficientMembersToVoteLeader
}
The following lines declare a Party
class that takes advantage of generics to work with many types. The class name is followed by a less than sign (<
), a T
that identifies the generic type parameter, a colon (:
), and a protocol name that the T
generic type parameter must conform to, which is the AnimalProtocol
protocol. Then, the where
keyword, followed by T
(which identified the type) and a colon (:
) that indicates that the T
generic type parameter has to be a type that also conforms to another protocol—that is, the Equatable
protocol. Finally, the greater than sign (>
) ends the type constraints declaration that is included...