Skip to content

Commit 358af3f

Browse files
committed
For with Labels
1 parent 1f5b092 commit 358af3f

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

for_with_label/main.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
7+
Next:
8+
// No code between label and for loop
9+
for i := 0; ; i++ {
10+
for j := 0; ; j++ {
11+
if j == 1 {
12+
fmt.Println("Continue to next outer iteration")
13+
continue Next
14+
}
15+
if i == 1 {
16+
fmt.Println("Breaking out of all loops")
17+
break Next
18+
}
19+
}
20+
}
21+
fmt.Println("First Statement after Next Label")
22+
}

longest_substring/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Given a string, find the length of the longest substring without repeating characters.
1+
//Given a string, find the longest substring without repeating characters.
22
//
33
//Example 1:
44
//

runes_bytes_loops/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Runes, bytes and range loops gotchas
2+
13
package main
24

35
import (

0 commit comments

Comments
 (0)