Going Loopy              adventures in iteration with Google Go                         Eleanor McHughGoing Loopy         ...
the conditional loopGoing Loopy            2     http://slides.games-with-brains.net/
package main        import "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s); ...
package main        import "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s); ...
package main        import "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s); ...
package main        import "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s); ...
package main        import "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s); ...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s)...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s)...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s)...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s)...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s)...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s)...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s)...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s)...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s)...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s)...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s)...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s)...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s)...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s)...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i := 0; i < len(s)...
the infinite loopGoing Loopy          23    http://slides.games-with-brains.net/
package main        import . "fmt"        func main() {          defer func() {            recover()          }()         ...
package main        import . "fmt"        func main() {          defer func() {            recover()          }()         ...
package main        import . "fmt"        func main() {          defer func() {            recover()          }()         ...
package main        import . "fmt"        func main() {          defer func() {            recover()          }()         ...
package main        import . "fmt"        func main() {          defer func() {            recover()          }()         ...
the rangeGoing Loopy       29      http://slides.games-with-brains.net/
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i, v := range s { ...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i, v := range s { ...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i, v := range s { ...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i, v := range s { ...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i, v := range s { ...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          for i, v := range s { ...
a functional interludeGoing Loopy        36    http://slides.games-with-brains.net/
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice(0, 2, 4, 6, 8)        }        func print_sli...
package main        import . "fmt"        func main() {          print_slice(0, 2, 4, 6, 8)        }        func print_sli...
package main        import . "fmt"        func main() {          print_slice(0, 2, 4, 6, 8)        }        func print_sli...
asserting typeGoing Loopy         44    http://slides.games-with-brains.net/
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
package main        import . "fmt"        func main() {          print_slice([]int{0, 2, 4, 6, 8})        }        func pr...
closuresGoing Loopy      60      http://slides.games-with-brains.net/
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          print_slice(func(i int...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          print_slice(func(i int...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          print_slice(func(i int...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          print_slice(func(i int...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          print_slice(func(i int...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          print_slice(func(i int...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          print_slice(func(i int...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          print_slice(func(i int...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          print_slice(func(i int...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          print_slice(func(i int...
upon reflectionGoing Loopy         71    http://slides.games-with-brains.net/
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          print_values(s)       ...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          print_values(s)       ...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          print_values(s)       ...
package main        import . "fmt"        func main() {          s := []int{0, 2, 4, 6, 8}          print_values(s)       ...
package main        import . "fmt"        import . "reflect"        func main() {          s := []int{0, 2, 4, 6, 8}      ...
package main        import . "fmt"        import . "reflect"        func main() {          s := []int{0, 2, 4, 6, 8}      ...
package main        import . "fmt"        import . "reflect"        func main() {          s := []int{0, 2, 4, 6, 8}      ...
package main        import . "fmt"        import . "reflect"        func main() {          s := []int{0, 2, 4, 6, 8}      ...
package main        import . "fmt"        import . "reflect"        func main() {          s := []int{0, 2, 4, 6, 8}      ...
package main        import . "fmt"        import . "reflect"        func main() {          s := []int{0, 2, 4, 6, 8}      ...
package main        import . "fmt"        import . "reflect"        func main() {          s := []int{0, 2, 4, 6, 8}      ...
package main        import . "fmt"        import . "reflect"        func main() {          s := []int{0, 2, 4, 6, 8}      ...
package main        import . "fmt"        import . "reflect"        func main() {          s := []int{0, 2, 4, 6, 8}      ...
package main        import . "fmt"        import . "reflect"        func main() {          s := []int{0, 2, 4, 6, 8}      ...
package main        import . "fmt"        import . "reflect"        func main() {          s := []int{0, 2, 4, 6, 8}      ...
package main        import . "fmt"        import . "reflect"        func main() {          s := []int{0, 2, 4, 6, 8}      ...
package main        import . "fmt"        import . "reflect"        func main() {          s := []int{0, 2, 4, 6, 8}      ...
package main        import . "fmt"        import . "reflect"        func main() {          s := []int{0, 2, 4, 6, 8}      ...
http://golang.org/       #golang
Upcoming SlideShare
Loading in …5
×

Going Loopy

763 views

Published on

A short presentation on loops, closures and reflection in Go

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
763
On SlideShare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
16
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Going Loopy

    1. 1. Going Loopy adventures in iteration with Google Go Eleanor McHughGoing Loopy 1 http://slides.games-with-brains.net/
    2. 2. the conditional loopGoing Loopy 2 http://slides.games-with-brains.net/
    3. 3. package main import "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { fmt.Printf("%v: %vn", i, s[i]) } }Going Loopy 3 http://slides.games-with-brains.net/
    4. 4. package main import "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { fmt.Printf("%v: %vn", i, s[i]) } } 0: 0 1: 2 2: 4 3: 6 4: 8Going Loopy 4 http://slides.games-with-brains.net/
    5. 5. package main import "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { fmt.Printf("%v: %vn", i, s[i]) } }Going Loopy 5 http://slides.games-with-brains.net/
    6. 6. package main import "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { fmt.Printf("%v: %vn", i, s[i]) } }Going Loopy 6 http://slides.games-with-brains.net/
    7. 7. package main import "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { fmt.Printf("%v: %vn", i, s[i]) } }Going Loopy 7 http://slides.games-with-brains.net/
    8. 8. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 8 http://slides.games-with-brains.net/
    9. 9. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 9 http://slides.games-with-brains.net/
    10. 10. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 10 http://slides.games-with-brains.net/
    11. 11. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 11 http://slides.games-with-brains.net/
    12. 12. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 12 http://slides.games-with-brains.net/
    13. 13. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 13 http://slides.games-with-brains.net/
    14. 14. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 14 http://slides.games-with-brains.net/
    15. 15. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 15 http://slides.games-with-brains.net/
    16. 16. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 16 http://slides.games-with-brains.net/
    17. 17. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 17 http://slides.games-with-brains.net/
    18. 18. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 18 http://slides.games-with-brains.net/
    19. 19. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 19 http://slides.games-with-brains.net/
    20. 20. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 20 http://slides.games-with-brains.net/
    21. 21. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 21 http://slides.games-with-brains.net/
    22. 22. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i := 0; i < len(s); i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 22 http://slides.games-with-brains.net/
    23. 23. the infinite loopGoing Loopy 23 http://slides.games-with-brains.net/
    24. 24. package main import . "fmt" func main() { defer func() { recover() }() s := []int{0, 2, 4, 6, 8} for i := 0; ; i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 24 http://slides.games-with-brains.net/
    25. 25. package main import . "fmt" func main() { defer func() { recover() }() s := []int{0, 2, 4, 6, 8} for i := 0; ; i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 25 http://slides.games-with-brains.net/
    26. 26. package main import . "fmt" func main() { defer func() { recover() }() s := []int{0, 2, 4, 6, 8} for i := 0; ; i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 26 http://slides.games-with-brains.net/
    27. 27. package main import . "fmt" func main() { defer func() { recover() }() s := []int{0, 2, 4, 6, 8} for i := 0; ; i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 27 http://slides.games-with-brains.net/
    28. 28. package main import . "fmt" func main() { defer func() { recover() }() s := []int{0, 2, 4, 6, 8} for i := 0; ; i++ { Printf("%v: %vn", i, s[i]) } }Going Loopy 28 http://slides.games-with-brains.net/
    29. 29. the rangeGoing Loopy 29 http://slides.games-with-brains.net/
    30. 30. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i, v := range s { Printf("%v: %vn", i, v) } }Going Loopy 30 http://slides.games-with-brains.net/
    31. 31. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i, v := range s { Printf("%v: %vn", i, v) } }Going Loopy 31 http://slides.games-with-brains.net/
    32. 32. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i, v := range s { Printf("%v: %vn", i, v) } }Going Loopy 32 http://slides.games-with-brains.net/
    33. 33. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i, v := range s { Printf("%v: %vn", i, v) } }Going Loopy 33 http://slides.games-with-brains.net/
    34. 34. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i, v := range s { Printf("%v: %vn", i, v) } }Going Loopy 34 http://slides.games-with-brains.net/
    35. 35. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} for i, v := range s { Printf("%v: %vn", i, v) } }Going Loopy 35 http://slides.games-with-brains.net/
    36. 36. a functional interludeGoing Loopy 36 http://slides.games-with-brains.net/
    37. 37. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s []int) { for i, v := range s { Printf("%v: %vn", i, v) } }Going Loopy 37 http://slides.games-with-brains.net/
    38. 38. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s []int) { for i, v := range s { Printf("%v: %vn", i, v) } }Going Loopy 38 http://slides.games-with-brains.net/
    39. 39. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s []int) { for i, v := range s { Printf("%v: %vn", i, v) } }Going Loopy 39 http://slides.games-with-brains.net/
    40. 40. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s []int) { for i, v := range s { Printf("%v: %vn", i, v) } }Going Loopy 40 http://slides.games-with-brains.net/
    41. 41. package main import . "fmt" func main() { print_slice(0, 2, 4, 6, 8) } func print_slice(s ...int) { for i, v := range s { Printf("%v: %vn", i, v) } }Going Loopy 41 http://slides.games-with-brains.net/
    42. 42. package main import . "fmt" func main() { print_slice(0, 2, 4, 6, 8) } func print_slice(s ...int) { for i, v := range s { Printf("%v: %vn", i, v) } }Going Loopy 42 http://slides.games-with-brains.net/
    43. 43. package main import . "fmt" func main() { print_slice(0, 2, 4, 6, 8) } func print_slice(s ...int) { for i, v := range s { Printf("%v: %vn", i, v) } }Going Loopy 43 http://slides.games-with-brains.net/
    44. 44. asserting typeGoing Loopy 44 http://slides.games-with-brains.net/
    45. 45. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { for i, v := range s.([]int) { Printf("%v: %vn", i, v) } }Going Loopy 45 http://slides.games-with-brains.net/
    46. 46. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { for i, v := range s.([]int) { Printf("%v: %vn", i, v) } }Going Loopy 46 http://slides.games-with-brains.net/
    47. 47. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { for i, v := range s.([]int) { Printf("%v: %vn", i, v) } }Going Loopy 47 http://slides.games-with-brains.net/
    48. 48. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { if s, ok := s.([]int); ok { for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 48 http://slides.games-with-brains.net/
    49. 49. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { if s, ok := s.([]int); ok { for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 49 http://slides.games-with-brains.net/
    50. 50. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { if s, ok := s.([]int); ok { for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 50 http://slides.games-with-brains.net/
    51. 51. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { if s, ok := s.([]int); ok { for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 51 http://slides.games-with-brains.net/
    52. 52. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { if s, ok := s.([]int); ok { for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 52 http://slides.games-with-brains.net/
    53. 53. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { if s, ok := s.([]int); ok { for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 53 http://slides.games-with-brains.net/
    54. 54. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { switch s := s.(type) { case []int: for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 54 http://slides.games-with-brains.net/
    55. 55. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { switch s := s.(type) { case []int: for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 55 http://slides.games-with-brains.net/
    56. 56. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { switch s := s.(type) { case []int: for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 56 http://slides.games-with-brains.net/
    57. 57. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { switch s := s.(type) { case []int: for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 57 http://slides.games-with-brains.net/
    58. 58. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { switch s := s.(type) { case []int: for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 58 http://slides.games-with-brains.net/
    59. 59. package main import . "fmt" func main() { print_slice([]int{0, 2, 4, 6, 8}) } func print_slice(s interface{}) { switch s := s.(type) { case []int: for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 59 http://slides.games-with-brains.net/
    60. 60. closuresGoing Loopy 60 http://slides.games-with-brains.net/
    61. 61. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } }Going Loopy 61 http://slides.games-with-brains.net/
    62. 62. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } }Going Loopy 62 http://slides.games-with-brains.net/
    63. 63. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } }Going Loopy 63 http://slides.games-with-brains.net/
    64. 64. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } }Going Loopy 64 http://slides.games-with-brains.net/
    65. 65. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } }Going Loopy 65 http://slides.games-with-brains.net/
    66. 66. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } }Going Loopy 66 http://slides.games-with-brains.net/
    67. 67. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } }Going Loopy 67 http://slides.games-with-brains.net/
    68. 68. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } }Going Loopy 68 http://slides.games-with-brains.net/
    69. 69. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } }Going Loopy 69 http://slides.games-with-brains.net/
    70. 70. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_slice(func(i int) int { return s[i] }) } func print_slice(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } } }Going Loopy 70 http://slides.games-with-brains.net/
    71. 71. upon reflectionGoing Loopy 71 http://slides.games-with-brains.net/
    72. 72. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] * 2 }) } func print_values(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } case []int: for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 72 http://slides.games-with-brains.net/
    73. 73. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] * 2 }) } func print_values(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } case []int: for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 73 http://slides.games-with-brains.net/
    74. 74. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] * 2 }) } func print_values(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } case []int: for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 74 http://slides.games-with-brains.net/
    75. 75. package main import . "fmt" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] * 2 }) } func print_values(s interface{}) { switch s := s.(type) { case func(int) int: for i := 0; i < 5; i++ { Printf("%v: %vn", s(i)) } case []int: for i, v := range s { Printf("%v: %vn", i, v) } } }Going Loopy 75 http://slides.games-with-brains.net/
    76. 76. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface{}) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i)) } } }Going Loopy 76 http://slides.games-with-brains.net/
    77. 77. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface{}) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i)) } } }Going Loopy 77 http://slides.games-with-brains.net/
    78. 78. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } }Going Loopy 78 http://slides.games-with-brains.net/
    79. 79. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } }Going Loopy 79 http://slides.games-with-brains.net/
    80. 80. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } }Going Loopy 80 http://slides.games-with-brains.net/
    81. 81. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } }Going Loopy 81 http://slides.games-with-brains.net/
    82. 82. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } }Going Loopy 82 http://slides.games-with-brains.net/
    83. 83. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } }Going Loopy 83 http://slides.games-with-brains.net/
    84. 84. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } }Going Loopy 84 http://slides.games-with-brains.net/
    85. 85. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } }Going Loopy 85 http://slides.games-with-brains.net/
    86. 86. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } }Going Loopy 86 http://slides.games-with-brains.net/
    87. 87. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } }Going Loopy 87 http://slides.games-with-brains.net/
    88. 88. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } }Going Loopy 88 http://slides.games-with-brains.net/
    89. 89. package main import . "fmt" import . "reflect" func main() { s := []int{0, 2, 4, 6, 8} print_values(s) print_values(func(i int) int { return s[i] }) } func print_values(s interface{}) { switch s := ValueOf(s); s.Kind() { case Func: p := []Value{ ValueOf(i) } for i := 0; i < 5; i++ { Printf("%v: %vn", s.Call(p)[0].Interface()) } case Slice: for i := 0; i < s.Len(); i++ { Printf("%v: %vn", i, s.Index(i).Interface()) } } }Going Loopy 89 http://slides.games-with-brains.net/
    90. 90. http://golang.org/ #golang

    ×