0. Getting Started

0.0 about slice

  • slicesare like reference to arrays (underlying array), they don’t store any data.
  • slicesare dynamically-sized, they have a “special” way to extend theirs’ capacity

  • A closureis a function value that references variables from outside its body.

  • A closureis bound to its own variable, diffenert initialization of the closure is different. ```go package main

import “fmt”

func fibonacci() func() int{ pre, now := 0, 1 return func() int { now = pre + now pre = now - pre return pre } } func main() { f := fibonacci() for i := 0; i < 10; i ++ { fmt.Println(f()) } } ```

0.2 about receiver

  • receiveris a special argument for methods, it is the type that the methods defined on.
  • methods with pointer receivercan modify the original value of the type that they are defined on.

  • 0.3 about