daily pastebin goal
18%
SHARE
TWEET

[Go] Type assertion.

cwchen Oct 7th, 2017 557 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5. )
  6.  
  7. func main() {
  8.     var im interface{}
  9.     var in interface{}
  10.  
  11.     im = 3
  12.     in = 2
  13.  
  14.     // type assertion
  15.     m := im.(int)
  16.     n := in.(int)
  17.  
  18.     fmt.Println(m + n)
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top