Explore the problem solved by generics.
- [Instructor] Although this course is about POP,…we can't avoid talking about generics.…They are so deeply rooted in the language…that we don't even notice that we're relying on generics.…Actually, whenever we encounter protocols,…we'll usually also see generics.…As an example, the built-in Swift collection types…are conforming to the collection protocol,…and to other protocols as well,…but they are also implemented as generic types…so that they can work with any type.…
Swift is a type-safe language,…yet there may be cases when we can't provide…the exact type when declaring a type or a function.…To demonstrate the problem,…let's assume that we need a function…that tells whether two values are equal.…We could come up with the following solution.…It works, except that it only lets us…compare two Int values.…To compare two values of type double,…we'd need to create a new function,…but this won't work with float types,…so we end up creating yet another function…which accepts float types.…
Later on, we may need to support…
- Comparing object-oriented programming with protocol-oriented programming
- Methods and class-bound protocols
- Adopting a protocol
- Declaring asynchronous behavior
- Preparing and implementing fallback logic
- Implementing an app using protocol-oriented programming
Skill Level Intermediate
1. Protocol-Oriented Programming
4. Implement the Weather App Using POP
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.