Swift Generics: The Key to Reusable and Flexible Code

  Рет қаралды 6,385

Swift and Tips

Swift and Tips

Күн бұрын

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/e4876...
Content:
0:00 - Intro
0:35 - What are generics?
5:50 - Why not using Any instead of generics?
9:39 - Type Constraints
12:22 - Generic Types
15:52 - Extending a generic type
17:13 - Using generics in SwiftUI
22:52 - Outro
------
References:
- docs.swift.org/swift-book/Lan...
- developer.apple.com/videos/pl...
- www.swiftbysundell.com/basics...
Source code showed in this video: github.com/pitt500/swift-and-...
------
Other videos in the channel:
- Protocols in Swift: • Protocols
- UIKit in SwiftUI: • UIKit in SwiftUI
- Struct vs Classes: • Structs vs classes in ...
-----
Don't forget to subscribe to the channel, like it, and follow me on social media:
Twitter:
/ swiftandtips
/ pitt500
Finally, ask me for a video you would like to see next 😄!
Credits:
- Music by Wataboi from pixabay.com/
- Video edited with LumaFusion

Пікірлер: 27
@gacastro
@gacastro 3 жыл бұрын
Nice summary and practical example of generics. 👍 Looking forward to your next video on protocols and associated types.
@swiftandtips
@swiftandtips 3 жыл бұрын
Thank you Gonzalo! 😄
@adlsfreund
@adlsfreund 3 жыл бұрын
Comprehensive video! You put a lot of effort into this. Looking forward to the next one. Greetings from Scotland!
@swiftandtips
@swiftandtips 3 жыл бұрын
Thank you so much @adlsfreund for your support!! ☺️. I would like to visit Scotland in a future btw, wonderful country!
@swift_goose
@swift_goose 3 жыл бұрын
Very informative, thank for sharing this!
@swiftandtips
@swiftandtips 3 жыл бұрын
Hi @Swift, You’re welcome! Thanks for your comment!
@mig12394
@mig12394 3 жыл бұрын
Thanks for this auto, Looking forward to the next one. Greetings from France!
@swiftandtips
@swiftandtips 3 жыл бұрын
Merci Beaucoup @michel! 😃
@lennyedwards62
@lennyedwards62 3 жыл бұрын
Thanks. Useful video.
@yogeshbhatt3806
@yogeshbhatt3806 Жыл бұрын
That is amazing video for Generics. Thanks
@swiftandtips
@swiftandtips Жыл бұрын
You’re welcome, Glad it helped you! 😄
@Jager-yoo
@Jager-yoo 2 жыл бұрын
Good video. thanks!
@swiftandtips
@swiftandtips 2 жыл бұрын
You’re welcome ☺️!
@Rethinam81
@Rethinam81 2 жыл бұрын
Excellent
@nareshy8379
@nareshy8379 3 жыл бұрын
awesome explanation..
@swiftandtips
@swiftandtips 3 жыл бұрын
Thank you @Naresh!
@marcospolanco8349
@marcospolanco8349 3 жыл бұрын
thank you very much. it was very useful.
@swiftandtips
@swiftandtips 3 жыл бұрын
Thank you Marcos! 😁
@KK-pq6lu
@KK-pq6lu 3 жыл бұрын
Good vid.
@swiftandtips
@swiftandtips 3 жыл бұрын
Thank you! 😄
@andrejkling3886
@andrejkling3886 2 жыл бұрын
Excellent explanation... thank you so much. Can made more videos how we can use protocols and generic in real App?
@swiftandtips
@swiftandtips 2 жыл бұрын
Great suggestion! I will work on that later in the future. Thank you!
@swiftandtips
@swiftandtips 2 жыл бұрын
By the way, arrays are a great example for that 😉
@andrejkling3886
@andrejkling3886 2 жыл бұрын
@@swiftandtips yes, exactly... good to see more solutions
@andrejkling3886
@andrejkling3886 2 жыл бұрын
@@swiftandtips thank you for great content! Keep going
Generics in Swift: Protocols with associated types
15:37
Swift and Tips
Рет қаралды 9 М.
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 126 МЛН
I'm Excited To see If Kelly Can Meet This Challenge!
00:16
Mini Katana
Рет қаралды 29 МЛН
Alex hid in the closet #shorts
00:14
Mihdens
Рет қаралды 18 МЛН
Opaque types: Masking your concrete types
22:18
Swift and Tips
Рет қаралды 4,3 М.
This is what you can do with Enums in Swift
19:13
Swift and Tips
Рет қаралды 5 М.
Async/Await in Swift | Comparison vs Closures and Combine Framework
19:59
How to use Generics in Swift | Advanced Learning #8
19:24
Swiftful Thinking
Рет қаралды 14 М.
Introduction to Generics in Swift
24:14
Stewart Lynch
Рет қаралды 5 М.
Gentle Generics - John Sundell at Hacking with Swift Live 2019
29:27
How do Actors work in Swift?
19:05
Swift and Tips
Рет қаралды 4 М.
Generics: The most intimidating TypeScript feature
18:19
Matt Pocock
Рет қаралды 169 М.
Swinject: Effortless Dependency Injection in iOS (Basics)
12:45
iOS Academy
Рет қаралды 28 М.
Что делать если в телефон попала вода?
0:17
Лена Тропоцел
Рет қаралды 3,4 МЛН
Как противодействовать FPV дронам
44:34
Стратег Диванного Легиона
Рет қаралды 88 М.
iPhone 15 Pro в реальной жизни
24:07
HUDAKOV
Рет қаралды 496 М.
Опасность фирменной зарядки Apple
0:57
SuperCrastan
Рет қаралды 12 МЛН