This commit is contained in:
2024-10-20 21:07:51 +00:00
parent ac623d6d49
commit ed60288a2a
8 changed files with 82 additions and 32 deletions

3
pointers/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module example.com/pointers
go 1.23.1

22
pointers/pointers.go Normal file
View File

@@ -0,0 +1,22 @@
package main
import "fmt"
func main() {
age := 32
var agePointer *int
agePointer = &age
fmt.Println("Age:", *agePointer)
editAgeToAdultYears(agePointer)
fmt.Println(age)
}
func editAgeToAdultYears(age *int) {
// return *age - 18
*age = *age - 18
}