Learn Courses My Dashboard

14 Days Beginner Challenge Lession 8

Hello everyone Please i try to run the code onthe Lession 8 of the 14 Days Beginner Challenge
There is no error and there is also no output I would be glad if anyone could assist me

struct Car {
var make = “Tesla”
var model = “Far”
var year = “2022”
var details:String{
return make + model + year
}

func getDetails ()-> String{
  return(details)
}

}

this is codes i rworte in the playGround of the Xcode

Thanks wonderful community.

Welcome to the community!

You’ve defined a function called getDetails()

But you haven’t actually called (executed the function)

add getDetails() in your playground and you should see an output

Basically it’s like you bought a car, but never actually drove it anywhere

If you go back to the Challenge description is says that the 4 properties inside the struct also need to be private and the purpose of that is so that they cannot be accessed outside the struct. So each should be defined:

private var .....

Hint:
In order to get the function inside the struct to be executed you have to create an instance of the struct and then use that instance to call the function getDetails using dot notation.