- short declaration operator
- you can only use short declaration inside block scope
- scope: block, package
- multi-variable short declaration
- var initializes to zero value
-
slice
-
map
-
struct
- composite data structure
- create programs through composition
- create your own named type with an underlying type & use a composite literal
- create your own anonymous type with an underlying type & use a composite literal
- embed types
- methods
- interface
- create a type square
- create a type circle
- attach a method to each that calculates area and returns it
- create a type shape which defines an interface as anything which has the area method
- create a func info which takes type shape and then prints the area
- create a value of type square
- create a value of type circle
- use func info to print the area of square
- use func info to print the area of circle
- create a struct that holds person fields
- create a struct that holds secret agent fields and embeds person type
- attach a method to person: pSpeak
- attach a method to secret agent: saSpeak
- create a variable of type person
- create a variable of type secret agent
- print a field from person
- run pSpeak attached to the variable of type person
- print a field from secret agent
- run saSpeak attached to the variable of type secret agent
- run pSpeak attached to the variable of type secret agent
- create an interface type that both person and secretAgent implement
- declare a func with a parameter of the interface’s type
- call that func in main and pass in a value of type person
- call that func in main and pass in a value of type secretAgent
Thank you to @BenCarter78 for that cool solution.
- solution & optional additional info not necessary to know: assertions