forked from steger/pr3-sose2026
28 lines
708 B
Go
28 lines
708 B
Go
package myMath
|
|
|
|
import "fmt"
|
|
|
|
// init is a special function that is called automatically when the package is imported. It is used to initialize the package
|
|
// and can be used to set up any necessary state or perform any necessary setup before the package is used.
|
|
func init() {
|
|
fmt.Println("initializing myMath")
|
|
}
|
|
|
|
// functions that start with an uppercase letter are exported and can be accessed from outside the package
|
|
func Add(a, b int) int {
|
|
return a + b
|
|
}
|
|
|
|
// functions that start with a lowercase letter are not exported and cannot be accessed from outside the package
|
|
func greater(a, b int) bool {
|
|
return a > b
|
|
}
|
|
|
|
func Min(a, b int) int {
|
|
if greater(a, b) {
|
|
return b
|
|
} else {
|
|
return a
|
|
}
|
|
}
|