Learn Courses My Dashboard

Lesson 8 Challenge (14 Day Code) Why is it not printing anything?

struct Car {

var make:String = "Toyota"
var model:String = "Camry"
var year:String = "1999"

var details:String {
    return year + make + model

func getDetails() {


Welcome to the community!

You need to call your function!

You’re defining the function, saying what it does, but you’re never actually calling, or executing it.

Call it like this:

1 Like

Hi, You need to create an instance of the Struct after your Struct code declaration in order to utilise it. All is explained in Lesson 9.

// 1. after the last curly bracket, assign an instance of the Car() Struct to a var of type Car.
var myCar:Car = Car()

// 2. call the getDetails() Method from the Struct by using dot notation on your instance…

You will also need to edit your details computed property to include spaces e.g.
return year + " " + make + " " + model

1 Like