mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 05:11:49 +08:00
update book code
This commit is contained in:
32
eBook/exercises/chapter_5/multiple_for.go
Normal file → Executable file
32
eBook/exercises/chapter_5/multiple_for.go
Normal file → Executable file
@@ -1,17 +1,17 @@
|
||||
// multiple_for.go
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
//multiple initialization; a consolidated bool expression with && and ||; multiple ‘incrementation’
|
||||
for i, j, s := 0, 5, "a"; i < 3 && j < 100 && s != "aaaaa"; i, j, s = i+1,
|
||||
j+1, s + "a" {
|
||||
fmt.Println("Value of i, j, s:", i, j, s)
|
||||
}
|
||||
}
|
||||
/* Output:
|
||||
Value of i, j, s: 0 5 a
|
||||
Value of i, j, s: 1 6 aa
|
||||
Value of i, j, s: 2 7 aaa
|
||||
// multiple_for.go
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
//multiple initialization; a consolidated bool expression with && and ||; multiple ‘incrementation’
|
||||
for i, j, s := 0, 5, "a"; i < 3 && j < 100 && s != "aaaaa"; i, j, s = i+1,
|
||||
j+1, s + "a" {
|
||||
fmt.Println("Value of i, j, s:", i, j, s)
|
||||
}
|
||||
}
|
||||
/* Output:
|
||||
Value of i, j, s: 0 5 a
|
||||
Value of i, j, s: 1 6 aa
|
||||
Value of i, j, s: 2 7 aaa
|
||||
*/
|
Reference in New Issue
Block a user