Skip to content

Commit e8e76d0

Browse files
xljxlj
authored andcommitted
fix fmt error
1 parent 9969338 commit e8e76d0

7 files changed

Lines changed: 31 additions & 33 deletions

File tree

114-For/for-4.gop

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
sum := 0
55
i := 1
66
for i <= 100 {
7-
sum += i
8-
i++
7+
sum += i
8+
i++
99
}
1010
println sum
1111

1212
for {
13-
if sum > 0 {
14-
break
15-
}
13+
if sum > 0 {
14+
break
15+
}
1616
}
17-

114-For/for-5.gop

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Finally, there's the traditional C style for loop. It's safer than the while form because with the latter it's easy to forget to update the counter and get stuck in an infinite loop.
33

44
for i := 0; i < 10; i += 2 {
5-
if i == 6 {
6-
continue
7-
}
8-
println i
5+
if i == 6 {
6+
continue
7+
}
8+
println i
99
}

114-For/for-6.gop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
// Go+ also includes the continue keyword, which skips over rest of the body of a
88
// for loop and proceeds directly to the next iteration. Technically, you don’t need
9-
// a continue statement.
9+
// a continue statement.
1010

1111
for i := 1; i <= 100; i++ {
1212
if i%3 == 0 && i%5 == 0 {
@@ -22,4 +22,4 @@ for i := 1; i <= 100; i++ {
2222
break
2323
}
2424
println(i)
25-
}
25+
}

114-For/for-7.gop

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
samples := []string{"hello", "apple_π!"}
99
outer:
10-
for _, sample := range samples {
11-
for i, r := range sample {
12-
println(i, r, string(r))
13-
if r == 'l' {
14-
continue outer
10+
for _, sample := range samples {
11+
for i, r := range sample {
12+
println(i, r, string(r))
13+
if r == 'l' {
14+
continue outer
15+
}
1516
}
17+
println()
1618
}
17-
println()
18-
}

121-For-Each/for-each-1.gop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
// In Go+ there is no foreach loop instead, the for loop can be used as “foreach“. There is a keyword range, you can combine for and range together and have the choice of using the key or value within the loop.
1+
// In Go+ there is no foreach loop instead, the for loop can be used as “foreach“. There is a keyword range, you can combine for and range together and have the choice of using the key or value within the loop.

121-For-Each/for-each-2.gop

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
// key) is used instead.
88
//
99
// The second variable is frequently called v for value, but is sometimes given a
10-
// name based on the type of the values being iterated.
10+
// name based on the type of the values being iterated.
1111
//
1212
// If you don’t need to access the key, use an underscore (_) as the variable’s name. This tells Go+ to ignore the
13-
// value.
13+
// value.
1414

1515
evenVals := []int{2, 4, 6, 8, 10, 12}
1616
for _, v := range evenVals {
17-
println(v)
18-
}
17+
println(v)
18+
}

121-For-Each/for-each-3.gop

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
21
# Iterating Over Maps
32
// There’s something interesting about how a for-range loop iterates over a
43
// map.
54

65
m := map[string]int{
7-
"a": 1,
8-
"c": 3,
9-
"b": 2,
6+
"a": 1,
7+
"c": 3,
8+
"b": 2,
109
}
1110
for i := 0; i < 3; i++ {
12-
println("Loop", i)
13-
for k, v := range m {
14-
println(k, v)
15-
}
16-
}
11+
println("Loop", i)
12+
for k, v := range m {
13+
println(k, v)
14+
}
15+
}

0 commit comments

Comments
 (0)