Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Mixed operations

  • Cannot have operation between differen types
package main

import (
	"fmt"
)

func main() {
	a := 3
	b := 7.0

	sum := a + b
	fmt.Printf("sum %v\n", sum)

	div := a / b
	fmt.Printf("div %v\n", div)

}
# command-line-arguments
./numbers_mix.go:11:11: invalid operation: a + b (mismatched types int and float64)
./numbers_mix.go:14:11: invalid operation: a / b (mismatched types int and float64)