How to use Subscripts in Swift | Advanced Learning #32

How to use Subscripts in Swift | Advanced Learning #32

3.234 Lượt nghe
How to use Subscripts in Swift | Advanced Learning #32
In Swift, a subscript is a special method that allows you to access elements of a collection, sequence, or list by using square brackets []. Subscripts provide a convenient way to get or set values within an instance of a custom data type, such as a class, struct, or enum. 🤙 WELCOME BACK 🤙 WEBSITE: https://www.swiftful-thinking.com DISCORD: https://discord.gg/tSzJGx9RwE GITHUB: https://github.com/SwiftfulThinking/ SAY THANKS: https://www.buymeacoffee.com/nicksarno 00:00 Subscripts 01:25 Welcome back! 03:04 What is a subscript? 05:57 Replicating array accessor 07:48 Subscripts are type-unique 10:17 Example implementations 12:57 More examples 15:01 Forcing subscripts to fail 16:20 Subscripts for nested values 18:38 Wrapping up