add: arrays
This commit is contained in:
34
14-arrays/05-array-literal-example/main.go
Normal file
34
14-arrays/05-array-literal-example/main.go
Normal file
@ -0,0 +1,34 @@
|
||||
// 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"
|
||||
|
||||
// STORY:
|
||||
// Hipster's Love store publishes limited books
|
||||
// twice a year.
|
||||
//
|
||||
// The number of books they publish is fixed at 4.
|
||||
|
||||
// So, let's create a 4 elements string array for the books.
|
||||
|
||||
const (
|
||||
winter = 1
|
||||
summer = 3
|
||||
yearly = winter + summer
|
||||
)
|
||||
|
||||
func main() {
|
||||
books := [...]string{
|
||||
"Kafka's Revenge",
|
||||
"Stay Golden",
|
||||
"Everythingship",
|
||||
"Kafka's Revenge 2nd Edition",
|
||||
}
|
||||
fmt.Printf("books : %#v\n", books)
|
||||
}
|
Reference in New Issue
Block a user