sliceexpr.go
618 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// RUN: llgo -o %t %s
// RUN: %t 2>&1 | FileCheck %s
// CHECK: a
// CHECK-NEXT: 0 2
// CHECK-NEXT: 1 3
// CHECK-NEXT: b
// CHECK-NEXT: 0 3
// CHECK-NEXT: 1 4
// CHECK-NEXT: c
// CHECK-NEXT: 0 1
// CHECK-NEXT: 1 2
// CHECK-NEXT: d
// CHECK-NEXT: 0 1
// CHECK-NEXT: 1 2
// CHECK-NEXT: 2 3
// CHECK-NEXT: 3 4
package main
func main() {
x := []int{1, 2, 3, 4}
println("a")
for i, val := range x[1:3] {
println(i, val)
}
println("b")
for i, val := range x[2:] {
println(i, val)
}
println("c")
for i, val := range x[:2] {
println(i, val)
}
println("d")
for i, val := range x[:] {
println(i, val)
}
}