42 lines
851 B
Go
42 lines
851 B
Go
|
package main
|
||
|
|
||
|
import "fmt"
|
||
|
|
||
|
func slices() {
|
||
|
var notes []string
|
||
|
notes = make([]string, 7)
|
||
|
|
||
|
notes[0] = "do"
|
||
|
notes[1] = "re"
|
||
|
notes[2] = "mi"
|
||
|
|
||
|
fmt.Println(notes[0])
|
||
|
fmt.Println(notes[1])
|
||
|
fmt.Println(len(notes))
|
||
|
|
||
|
primes := make([]int, 5)
|
||
|
primes[0] = 2
|
||
|
primes[1] = 3
|
||
|
primes[2] = 5
|
||
|
primes[3] = 7
|
||
|
primes[4] = 11
|
||
|
fmt.Println(primes[0])
|
||
|
fmt.Println(primes[1])
|
||
|
fmt.Println(primes[2])
|
||
|
fmt.Println(primes[3])
|
||
|
fmt.Println(primes[4])
|
||
|
fmt.Println(len(primes))
|
||
|
|
||
|
literalNotes := []string{"do", "re", "mi", "fa", "so", "la", "ti"}
|
||
|
fmt.Println(literalNotes[3], literalNotes[6], literalNotes[0])
|
||
|
literalPrimes := []int{
|
||
|
2,
|
||
|
3,
|
||
|
5,
|
||
|
}
|
||
|
fmt.Println(literalPrimes[0], literalPrimes[1], literalPrimes[2])
|
||
|
fmt.Println(literalPrimes, len(literalPrimes))
|
||
|
literalPrimes = append(literalPrimes, 7, 11)
|
||
|
fmt.Println(literalPrimes, len(literalPrimes))
|
||
|
}
|