Hello guys, welcome to another video! Today we will continue with the Generics series talking about where clauses to constraint our associated type to a specific domain and modularize our code with the powers of generics and Swift's type inference. Also, in the end, I have a challenge for you: Merge two stacks and generate a new one, let's see if you got the idea about where clauses 👌🏼. Let me know in the comments if your solution was different from mine 😉!
Before continue I recommend you to watch the previous episodes:
Part 1 (Generics) : • Swift Generics: The Key to Reusable a...
Part 2 (Associated types): • Generics in Swift: Protocols with ass...
Started code for this video: https://gist.github.com/pitt500/c759b...
Content:
0:00 - Intro
0:35 - What are where clauses?
5:25 - Contextual Where Clauses
11:45 - Challenge: Merge two stacks
19:11 - Outro
------
References:
https://docs.swift.org/swift-book/Lan...
https://developer.apple.com/videos/pl...
https://www.swiftbysundell.com/basics...
Final code showed in this video: https://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 Swift
-----
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 https://pixabay.com/
Video edited with LumaFusion