Sign in
go
/
website
/
e7879e0f78ec3dbf8b9f42f3381d2a34a77fb423
/
.
/
_content
/
tour
/
methods
/
type-assertions.go
blob: 7e814998d1cfd1fbda1e2761aed4fc36e0f8db9d [
file
] [
log
] [
blame
]
// +build no-run 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)
}