Section10-Finished
This commit is contained in:
32
Section10/87.go
Normal file
32
Section10/87.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
var nums []int
|
||||
fmt.Printf("%#v\n", nums)
|
||||
|
||||
fmt.Printf("Lenght: %d, Capacity: %d \n", len(nums), cap(nums))
|
||||
|
||||
nums = append(nums, 1, 2)
|
||||
fmt.Printf("Lenght: %d, Capacity: %d \n", len(nums), cap(nums))
|
||||
|
||||
nums = append(nums, 3)
|
||||
fmt.Printf("Lenght: %d, Capacity: %d \n", len(nums), cap(nums))
|
||||
|
||||
nums = append(nums, 4)
|
||||
fmt.Printf("Lenght: %d, Capacity: %d \n", len(nums), cap(nums))
|
||||
|
||||
nums = append(nums, 5)
|
||||
fmt.Printf("Lenght: %d, Capacity: %d \n", len(nums), cap(nums))
|
||||
|
||||
nums = append(nums[0:4], 200, 300, 400, 500, 600)
|
||||
fmt.Printf("Lenght: %d, Capacity: %d \n", len(nums), cap(nums))
|
||||
fmt.Println(nums)
|
||||
|
||||
letters := []string{"A", "B", "C", "D", "E", "F"}
|
||||
letters = append(letters[:1], "X", "Y")
|
||||
fmt.Println(letters, len(letters), cap(letters))
|
||||
fmt.Println(letters[3:6])
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user