#!ek9
<?-
{
  "site": {
    "pages": [
      "flowControl.html"
    ],
    "title": "For loops with a guard, an assignment and a declaration",
    "kind": "good"
  },
  "keywords": [
    "for",
    "guard",
    "then"
  ],
  "primaryTopics": [
    "flowControl"
  ]
}
-?>
defines module site.flowControl.forguards

  defines function

    messagePrefix()
      <- rtn <- "SomePrefix-"

    forLoopWithGuard()
      stdout <- Stdout()

      prefix as String?
      for prefix :=? messagePrefix() then i in 1 ... 10
        stdout.println(`${prefix}${i}`)

    forLoopWithAssignment()
      stdout <- Stdout()

      prefix as String?
      for prefix: messagePrefix() then i in 1 ... 10
        stdout.println(`${prefix}${i}`)

    forLoopWithDeclaration()
      stdout <- Stdout()

      for prefix <- messagePrefix() then i in 1 ... 10
        stdout.println(`${prefix}${i}`)

      //Just to highlight that 'prefix' in the for loop - was scoped in the for loop only.
      prefix <- 21
      require prefix?
//EOF
