diff --git a/about_control_flow.go b/about_control_flow.go index 08564be..9b3438b 100644 --- a/about_control_flow.go +++ b/about_control_flow.go @@ -47,6 +47,25 @@ func testControlFlow() { case true: str = "second" } - assert(str == "second") // in the absence of value, truth is assumed + assert(str == "second") // in the absence of value, there is truth + } + + { + n := 0 + for i := 0; i < 5; i++ { + n += i + } + assert(n == 10) // for can have the structure with which we are all familiar + } + + { + n := 1 + for { + n *= 2 + if n > 20 { + break + } + } + assert(n == 32) // though omitting everything creates an infinite loop } }