Advertisement
cwchen

[Go] arithmetic operation between two different types.

Sep 7th, 2017
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.19 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5. )
  6.  
  7. func main() {
  8.     // a is an integer
  9.     a := 1
  10.  
  11.     // b is a floating-pointing number
  12.     b := 2.0
  13.  
  14.     // Error: mismatched types.
  15.     fmt.Println(a + b)
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement