add: first array examples

This commit is contained in:
Inanc Gumus
2018-11-15 16:37:09 +03:00
parent 5abce6adaf
commit 038a61e195
34 changed files with 448 additions and 28 deletions

View File

@ -1,3 +1,10 @@
// For more tutorials: https://blog.learngoprogramming.com
//
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
package main
import "fmt"
@ -19,6 +26,7 @@ const (
func main() {
// ALTERNATIVE:
// Use this only when you don't know about the elements beforehand
//
// var books [yearly]string
books := [yearly]string{
@ -28,30 +36,4 @@ func main() {
"Kafka's Revenge 2nd Edition",
}
fmt.Printf("books : %#v\n", books)
// var (
// wBooks [winter]string
// sBooks [summer]string
// )
// wBooks[0] = books[0]
// for i := range sBooks {
// sBooks[i] = books[i+1]
// }
// fmt.Printf("\nwinter : %#v\n", wBooks)
// fmt.Printf("\nsummer : %#v\n", sBooks)
// var published [len(books)]bool
// published[0] = true
// published[len(books)-1] = true
// fmt.Println("\nPublished Books:")
// for i, ok := range published {
// if ok {
// fmt.Printf("+ %s\n", books[i])
// }
// }
}