Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "log"
- )
- func main() {
- var im interface{}
- var in interface{}
- im = 3
- in = 2
- // type assertion
- m, ok := im.(int)
- if !ok {
- log.Fatal("Wrong type")
- }
- n, ok := in.(int)
- if !ok {
- log.Fatal("Wrong type")
- }
- fmt.Println(m + n)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement