April 2026
Intermediate
683 pages
25h 29m
English
In Chapter 5, you learned about generics in functions, and in Chapter 7, you learned that generics can be applied to enumerations too. Generics can be used with structs too! The syntax isn’t a far cry from what you’ve learned so far either, so this should be a smooth ride.
As the platform of our case study, Listing 8.33 features two structs: Student and Teacher. Note that they are not identical; Student has the name and grade properties, while Teacher has the name and subject properties.
struct Student { let name: String let grade: Int}struct Teacher { let name: String let subject: String}
Listing 8.33 Two Simple Structs
The purpose will be to build a third struct, which represents a committee of either students or ...
Read now
Unlock full access