Вопрос: Как сделать type switch?
Go
Junior
Без компании
Вопрос: Как сделать type switch?
Ответы
```go
func f(v any) {
switch x := v.(type) {
case int:
fmt.Println("int", x)
case string:
fmt.Println("string", x)
default:
fmt.Println("other")
}
}
```
**Как это работает:** type switch удобен для обработки `any`/интерфейсов по типам.