Summary
In this chapter, we learned how to declare structs. We started with the syntax to define a struct and then learned about initializing and accessing the struct fields. Then, we learned how to update the fields of a struct after initializing it.
After that, we discussed various methods of defining struct fields, which included fields with mutability, access scope, required attributes, and default values assigned. You are also able to define methods that belong to a struct and learned how to specify a struct as a field of another struct. Finally, we saw various approaches to pass struct fields and struct variables to a function that accepts a struct as an input argument, along with code examples.
The next chapter will help you to write and maintain modular code in V.