Module 1: Functions and Organization. Topic 1.1: Why Use Functions?

Слайд 2

What is a Function A set of instructions with a name

What is a Function

A set of instructions with a name (usually)

func

main() {
fmt.Printf("Hello, world.")
}

func PrintHello() {
fmt.Printf("Hello, world.")
}
func main() {
PrintHello()
}

Function declaration, name, call

Слайд 3

Reusability You only need to declare a function once Good for

Reusability

You only need to declare a function once
Good for commonly used

operations
Graphics editing program might have ThresholdImage()
Database program might have QueryDbase()
Music program might have ChangeKey()