← Back to archive

Stdle #166 · interfaces · 2026-11-19

What does this Go snippet output?

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

package main
import "fmt"
func describe(i interface{}) string {
switch i.(type) {
case int:
return "int"
case string:
return "string"
default:
return "other"
}
}
func main() {
fmt.Println(describe(3.14))
}
Interfaces
4 attempts left

Answer & explanation