0:00 / 0:00
Swift Generics: The Key to Reusable and Flexible Code
Swift and Tips
13K subscribers • 12 videos on Hallway
- Recommended by 1 person: 1 in engineering communities.
- Linked in the descriptionpitt500/swift-and-tips
Intermediate. Assumes working knowledge.
8.1K views5 years ago1 recommendation
Programming languagesMobile developmentSwiftiOS and SwiftUI
How to use generics in Swift to write reusable functions, classes, and data structures.
In this video, we will explore the power of generics in Swift and how they can be used to create reusable and flexible code. We will start by understanding the basics of generics and how they work in Swift. We will also explore how generics can be used in various scenarios such as creating generic data structures and writing reusable functions and classes. By the end of this video, you will have a solid understanding of how generics can be used to create reusable and flexible code in Swift, allowing you to write cleaner, more maintainable, and more efficient code. BackgroundGradientView: gist.github.com/pitt500/e4876b3618a3fc2fb60ba6e36e594064 Content: - Intro - What are generics? - Why not using Any instead of generics? - Type Constraints - Generic Types - Extending a generic type - Using generics in SwiftUI - Outro ------ References: - docs.swift.org/swift-book/LanguageGuide/Generics.html - developer.apple.com/videos/play/wwdc2018/406 - swiftbysundell.com/basics/generics/ Source code showed in this video: github.com/pitt500/swift-and-tips/tree/main/Generics ------ Other videos in the channel: - Protocols in Swift: youtube.com/playlist?list=PLHWvYoDHvsOX_H712wbhzSW0xqHsFy2j9 - UIKit in SwiftUI: youtube.com/playlist?list=PLHWvYoDHvsOX8vB95YIkv_r5e5IXWcyu2 - Struct vs Classes: youtu.be/zOeC7pxOIhk ----- Don't forget to subscribe to the channel, like it, and follow me on social media: Twitter: twitter.com/swiftandtips twitter.com/pitt500 Finally, ask me for a video you would like to see next 😄! Credits: - Music by Wataboi from pixabay.com/ - Video edited with LumaFusionWhy it's here
1 person recommends thisWhat people say. Recommended as a clear introduction to Swift generics and why they are preferred over using Any.