Based on this video's title, I "knew" the content, or so I thought. Since you can always be trusted, I gave it a spin anyway. And I learned! Thank you Stewart. You're a fantastic teacher.
Excellent! Appreciate the extra detail about setting up and using Playgrounds. When I first learned about guard statements, I thought of Beefeaters in front of a castle. If you're a variable, the guards will challenge you as you approach the gate. If you pass their challenge, you are granted access to the inner keep. Otherwise, hit the road! Also worth mentioning? If you present an optional variable, and it's unwrapped by the "guard let", the variable is available to code in the entire function. But, if the variable is unwrapped via an "if let", then the unwrapped variable is only available within the if statement's brackets. This is a great reason to lean towards using guard statements, rather than "if let".
Great tutorial with the comparisons! You always produce great content and it seems to always help me understand some nuance about the subject. Growing up on "IF" it has been harder for me to switch over but I have done so for the easier readability for others or even me in a year! LOL. Thanks Stewart!
In my early days of programming I would use a lot of Boolean algebra to deal with these types of checks. Now with years of experience behind me, my main objective is to make code more readable. Having multiple guard statements is far easier to read than a single statement containing a lot of && and/or ||. Now I'm not saying don't use Boolean algebra, I'm just saying if you feel the code is looking a bit unwieldy, you may want to refactor and simplify.
Thank you sir for these high quality videos. I appreciate how in depth your explanations are. Have you made a video in using closures as an alternative to protocol/delegate? If not I’d appreciate if you could provide an article that explains it well. Thanks again.
Based on this video's title, I "knew" the content, or so I thought. Since you can always be trusted, I gave it a spin anyway. And I learned! Thank you Stewart. You're a fantastic teacher.
You are not only a good programmer and teacher. You are also a great UA-camr and communicator. Keep the good work!
I really like the simple if logic, but I see my colleagues use a lot of guards so great that we have options here, thanks for the video!
Excellent! Appreciate the extra detail about setting up and using Playgrounds.
When I first learned about guard statements, I thought of Beefeaters in front of a castle. If you're a variable, the guards will challenge you as you approach the gate. If you pass their challenge, you are granted access to the inner keep. Otherwise, hit the road!
Also worth mentioning? If you present an optional variable, and it's unwrapped by the "guard let", the variable is available to code in the entire function. But, if the variable is unwrapped via an "if let", then the unwrapped variable is only available within the if statement's brackets. This is a great reason to lean towards using guard statements, rather than "if let".
Yes. With if let it is only valid with the brackets.
Ah True , but if you have a bottle of Gin with you you get a pass alla time
Great tutorial with the comparisons! You always produce great content and it seems to always help me understand some nuance about the subject. Growing up on "IF" it has been harder for me to switch over but I have done so for the easier readability for others or even me in a year! LOL. Thanks Stewart!
Glad the videos resonate with you Brad.
In my early days of programming I would use a lot of Boolean algebra to deal with these types of checks. Now with years of experience behind me, my main objective is to make code more readable. Having multiple guard statements is far easier to read than a single statement containing a lot of && and/or ||. Now I'm not saying don't use Boolean algebra, I'm just saying if you feel the code is looking a bit unwieldy, you may want to refactor and simplify.
Thank you sir for these high quality videos. I appreciate how in depth your explanations are.
Have you made a video in using closures as an alternative to protocol/delegate? If not I’d appreciate if you could provide an article that explains it well. Thanks again.
I haven’t as that is something I would do in UIKit, but only started creating videos when I switched pretty much entirely to SwiftUI.
thanks for the great examples
My pleasure!
Special…🔥👍
🔥🔥🔥 video
In this first example I'd have returned `person.age > 20 && person.gender == .female && person.skills.contains(.swiftui)`