1
0
Fork 0
This repository has been archived on 2023-05-11. You can view files and clone it, but cannot push or open issues or pull requests.
lesson-go_problems/5-type-assertions-in-go/main.go

20 lines
262 B
Go

package main
import "fmt"
func main() {
var i interface{} = "hello"
s := i.(string)
fmt.Println(s)
s, ok := i.(string)
fmt.Println(s, ok)
f, ok := i.(float64)
fmt.Println(f, ok)
f = i.(float64) // panic
fmt.Println(f)
}