This is what you can do with Enums in Swift

This is what you can do with Enums in Swift

Swift and Tips

55 лет назад

5,465 Просмотров

Hello everyone, today we will talk about my favorite feature in Swift: Enums

Enums are art because they help you to represent a finite number of possibilities in our software problems. Swift makes use of enums in A LOT OF WAYS. Let's begin and discover more about all its magic!

Content:
0:00 - Intro
0:27 - Blackjack Rules
0:54 - The problem that enums solve
2:01 - The basics
3:01 - Raw Values
4:30 - Enums support computer properties
5:09 - Avoid default in a Switch
6:09 - Blackjack Game
6:30 - CaseIterable
7:03 - Generate blackjack hands
7:23 - Associated Values
8:02 - Business logic for BlackJack
11:51 - Get associated values in a switch
12:31 - Protocols in Enums
13:16 - Recursive enums (Indirect)
15:00 - Getting a single case from an if
15:38 - BlackJack in SwiftUI
17:03 - Enum actions that represent UI events
18:58 - Do you want to learn more?

------

Source code shown in the video:
https://github.com/pitt500/swift-and-tips/tree/main/Enums

------
Resources:
* Swift.org: https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html
* Binary tree with enums: https://medium.com/@mrlauriegray/swift-3-enums-and-binary-search-trees-104f5e8d47e9

------
Other videos in the channel:
* Why can't you use Int indices in a String?: https://youtu.be/k35T7E1hxeQ
* LazyVStack: https://youtu.be/yrly21IFQdY
* GeometryReader and apple Watch animations: https://youtu.be/ma4LP8RnyI0
* What's new in SwiftUI 3.0: https://youtu.be/ewIeL1Trd5o
* Swift Concurrency: https://youtube.com/playlist?list=PLHWvYoDHvsOUsGazZVW_ZdehusA0diIxs


-----
Don't forget to subscribe to the channel, like it, and follow me on social media:

Twitter:
https://twitter.com/swiftandtips
https://twitter.com/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

Тэги:

#swift_and_tips #swift_&&_tips #swiftandtips #pitt500 #Pitt #Pedro_Rojas #Swift #ios #ios_development #swiftlang #iosdev #Enum #associated_value #raw_value #rawValue #CaseIterable #Switch #case #case_let #blackjack #SwiftUI #computer_properties #CustomStringConvertible #indirect #recursive_enums
Ссылки и html тэги не поддерживаются


Комментарии: