Skip to content
Quiz · Structs and methods · lesson 9 of 11

Quiz — embedding

What does the program print?

GO
package main

import "fmt"

type Animal struct{}
type Dog struct{ Animal }

func (a Animal) Kind() string { return "pet" }
func (a Animal) Say() string  { return a.Kind() }
func (d Dog) Kind() string    { return "dog" }

func main() { fmt.Println(Dog{}.Kind(), Dog{}.Say()) }

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way