A struct, or structure, is a custom data type in Swift that allows you to add many properties to it. If you think of a regular string, you can store just one string in the variable, as follows:
var firstName = "Matthew"
What if we wanted to add Matthews height:
var firstName = "Matthew"
var height = 190
This rapidly becomes complicated because we now have two variables to manage and think about. Imagine if we needed to add their last name, and so on, and then have the need to pass this information somewhere else within the program. This is one benefit of using a struct.
[Read more…]