Welcome to the Code Crew community.
I’ll add the details of the challenge that Chris Ching set and then talk about the questions you asked.
Adding private to the variables you have declared prevents them from being accessed externally. This means that make, model, year and details are only known to the methods and computed variables within the struct. From that you can see that getDetails() is the only object accessible externally.
This concept may take time to sink in but let that be OK. A lot of syntax in Swift can take time to understand. We all started at the ground level in the learning curve and that includes me.
It’s also OK if you opted to look at the solution to see what needed to be done.
To prove that the function getDetails() works what you need to do is declare an instance of the struct Car and then use that instance to reference getDetails(). You could do something like this:
let myCar = Car()
So breaking that down:
myCar is a copy of the struct
Car and the double closing brackets () is what is known as an initialiser.
Now you can access the available method inside the struct by saying
The dot . is known as using dot notation which enables you to access function and properties inside of structs (and classes). The only one you can access is getDetails().
I put that inside the print() function so that there would be some output in the console below the code editor.
If you try to access any of the variables you will get a compiler error. Eg, if you said:
myCar.make you will receive a error saying:
'make' is inaccessible due to 'private' protection level"