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

Numbers are passed by value

package main

import "fmt"

func main() {
	a := 1
	fmt.Printf("before %v\n", a)
	inc(a)
	fmt.Printf("after %v\n", a)
}

func inc(val int) {
	fmt.Printf("val in inc: %v\n", val)
	val++
	fmt.Printf("val in inc: %v\n", val)
}
before 1
val in inc: 1
val in inc: 2
after 1