package main
import "fmt"
var (
n = []int{1, 3, 5}
d = []string{"hage", "hoge"}
)
func main() {
fmt.Println(n)
// [1 3 5]
fmt.Println(n[0])
// 1
fmt.Println(n[1:])
// [3 5]
fmt.Println(n[2:])
// [5]
fmt.Println(n[3:])
// []
fmt.Println(n[:1])
// [1]
fmt.Println(n[:2])
// [1 3]
fmt.Println(n[:3])
// [1 3 5]
fmt.Println(d)
// [hage hoge]
fmt.Println(d[0])
// hage
}
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme