• Objects

    An object in programming is like a container that holds things. It can be used to store information like a box can store toys. For example, we could create an object called "cat" and it could have different pieces of information inside it like the cat's name, its color, or even how many lives it has left. Objects help us keep track of all the pieces of information we need for a program.

      • Map, Dictionary, Variable Objects

      • Go

        Example of object in go.
        package main
        
        import "fmt"
        
        func main() {
        	var person = map[string]interface{}{
        		"name": "John",
        		"age":  36,
        	}
        
        	fmt.Println(person["name"]) // John
        	fmt.Println(person["age"])  // 36
        }
        
      • Class Objects

      • Go

        Example of class object in go.
        package main
        
        import "fmt"
        
        type Person struct {
        	name string
        	age  int
        }
        
        func (p Person) greet() {
        	fmt.Println("Hello my name is " + p.name)
        }
        
        func main() {
        	var human = Person{"John", 36}
        
        	fmt.Println(human.name) // John
        	fmt.Println(human.age)  // 36
        	human.greet()		   // Hello my name is John
        }