Assigning values to anonymous fields

Report a typo

Suppose you have the Employee struct with two anonymous fields:

type Employee struct {
    string
    float64
}

Your task is to create the variable emp of the Employee struct type, and then assign values to each anonymous field of the struct; you can use any value you want so get creative! Just make sure to not change the declaration of the Employee struct.

Write a program in Go
package main

import "fmt"

// DO NOT modify the declaration of the Employee struct!
type Employee struct {
string
float64
}

func main() {
var emp Employee
// Assign values to the two anonymous fields of 'emp' below:

checkAnonymousField(emp) // DO NOT delete this line!
}
___

Create a free account to access the full topic