Initializing a struct

Report a typo

Below you will see a series of code snippets that initialize and create an instance of the Person struct that has the following fields:

type Person struct {
    Name string
    Age  int
}

Please select all the syntactically correct initializations of the Person struct.

a)

rick := Person{
    Name: "Rick",
    Age:  71,
}

b)

morty := new(Person)
morty = {
    Name: "Morty",
    Age:  15,
}

c)

var summer = Person{
   Name: "Summer",
   Age:  18,
}

d)

beth := new(Person)
beth.Name = "Beth"
beth.Age = 58
Select one or more options from the list
___

Create a free account to access the full topic