Hello, my name is Mark Nair, and in these lessons, you'll learn about data structures in Swift. We'll review structs, and then we'll look at value types. How do we use custom string convertible, stacks, and generics? Let's quickly review Swift structures or strucs. We use strucs when we need to create an entirely new type of data structure to work with. Let's take a look. Here, I'm going to declare a bicycle structure with the properties of name, tire, PSI, type, weight, and whether the bicycle is a comfy ride. So we start the keyword struct, and then we name our struct. In this case, I'll name it bicycle. And then we end this with curly braces, and inside of the curly braces we will put the properties of the strut. Now, since this is a property with no value, I'm gonna have to give it a type. So that's a string. So you can see here that I'm using different types name and brander strings. The PSI of the tire is an int, the weight of the bicycle is a double, and whether it's a comfy ride is a Bool. So now that I've made my structure, this means it is its own type. Now I can use this by creating an instance of this struct. Think about it like this. The struct is a blueprint, and that instance is the actual building we create from the blueprint. It looks like this. It's gonna make a new variable called touring bike. And that's gonna be equal to the type, which is gonna be the struct bicycle. Now, when I type the open parentheses in the popup I will see the values of the properties. I can just hit return, accept this, and now I can easily just tab from one to the other and put in the values. So what I've done here is I've said the name of the bike is Freyja, the brand is a Riese and Müller, the tire PSI is 25, the weight, pretty heavy, 64 pounds, and is it a comfy ride, true, it is. Let's make another instance. This is for road bike. Again, the bicycle is the type, this struct or the type. Open parenthesis gives me all my stuff, and then I can fill in the rest. Just like that. Now, to access this information, let's just attribute it to a new constant. And inside of here, I'll just put a string. Now, what I'd like to say is whatever the type of bike, the name of the bike, has a specific weight. And the way I do this is I access this information of the struct using dot syntax. So touring bike dot, and then there is my other information of the properties. I'll hit name. And then over here, touring bike dot weight. There we go. My Freyja bicycle weight, 64.3 pounds. Now really, maybe I'll use brand here, let's try this again. My Riese and Müller bicycle weighs 64.3 pounds. Pretty good. Let's try another one. So here's a structure named animal. Now we'll make an instance of animal. Same thing, here's my struct and then open parenthesis. Here are my properties, and then the species. Tiger has four legs and a tiger, yes, is an omnivore Now, to access that information, I'll just call Tony the Tiger and omnivore, and the result will be true. There it is. Now, before we can use an instance of our struct we have to initialize the instance. And here I'm initializing it inside of here. And I'll explain this in a second, but if I do something like this, get rid of this line. That doesn't work. So I'm trying to make Tony the Tiger destruct, but I can't because I don't have any values. I'm missing arguments in the parameters. So we could give the structure some default values like this. Now, when I give these values here, of course Swift is smart enough to realize what the type is, so I do not have to be explicit about that any longer. And just to remove any extra complexity in the code. But now if I look at Tony The tiger, and I call the dot species on it, I see that I have ape, but Tony the Tiger is a tiger, not an ape. So the default values, I want to override those default values. So that's when we use the memberwise initializer that we looked at a second ago. So up here, Tony, the tiger, it's the same thing except this parenthesis. I'm not gonna accept these default values. I'm going to override them by selecting this. You'll see here in the pop-up window, I have parenthesis and then parenthesis with the properties inside of it. The second one, just the parenthesis, is when I'm just going to accept the default values. But the first one is I'm gonna tell Swift, I need to do a little more work on this. Now, Tony, the Tiger is a tiger, and if I look at number of legs, four, great. But if I look at the status, it is true, even though I did not say in the memberwise initializer that Tony the Tiger is true to be an omnivore, I'm pulling that from the default value here of the struct so I don't have to be specific. All right, that is a quick overview of structs. Thanks for watching. Stay tuned for the next lesson where I'll show you what a value type is.