Sign in
go
/
tour
/
b43285f73498b03c246d9439a4bb695b83aab2ea
/
.
/
content
/
methods
/
type-assertions.go
blob: fcd5685f9036a8eeb8cdd0f575468cb81d6136d3 [
file
] [
log
] [
blame
]
// build +OMIT
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)
}