From 0aca59270b0cfaf32bd7da6431bc4f9ab5bb61b3 Mon Sep 17 00:00:00 2001 From: Steven Degutis Date: Thu, 15 Mar 2012 22:09:25 -0500 Subject: [PATCH] more koans but im drunk --- about_control_flow.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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 } }