- SYNTAX: func [receiver] funcName(){}
// Any variable of type "deck" now has access to the "print" method
// You can think of 'd' as 'this' or 'self' in OOP languages like Java or Python
- EXAMPLE: func (d deck) print() {
fmt.Println (deck)
}
- Because it's under the same package
- &variable - Gives a memory address of the value this variable is pointing to
- *pointer - Gives the value this memory address is pointing at
Assume person
is a struct
func (pointerToPerson *person) updateName() {
*pointerToPerson
}
*person - This is a type description it means we're working with a poitner to a person *pointerToPerson - This is an operator, it means we want to manipulate the value the pointer is referencing
- Turn
address
intovalue
with*address
- Turn
value
intoaddress
with&value
- int
- float
- string
- bool
- structs
- slices
- maps
- channels
- pointers
- functions