← Back to archive

Stdle #172 · interfaces · 2026-11-25

What does this Go snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

package main
import "fmt"
type Animal interface{ Sound() string }
type Dog struct{}
func (d Dog) Sound() string { return "woof" }
func main() {
var a Animal = Dog{}
d := a.(Dog)
fmt.Println(d.Sound())
}
Interfaces
4 attempts left

Answer & explanation