{"id":"word--while","name":"while","owner":"yeho","package":"language","kind":"keyword","signature":"while","description":"Repeat while a condition is true","context":"Use while when the stopping condition is more natural than a known collection or numeric range.","parameters":[],"returns":"","members":[],"tags":["complete-program","cpu","keyword","loops","yeho"],"updated":"2026-09-09","source":{"repository":"yeho","path":"parser_statements.cpp parseWhileStatement; Kyber loop runtime fixtures"},"status":"stable","notes":["The condition must be bool.","Update the condition's inputs inside the loop unless an external event owns progress."],"examples":[{"id":"complete","title":"Positive","description":"Use while when the stopping condition is more natural than a known collection or numeric range.","code":"thing point\n{\n    int x\n    int y\n\n    point(int x, int y)\n    {\n        this.x = x\n        this.y = y\n    }\n\n    Sum() -> int\n    {\n        return this.x + this.y\n    }\n}\n\nAdd(int left, int right) -> int\n{\n    return left + right\n}\n\npoint value = point(2, 3)\nint total = 0\nfor i from 0 < 4\n{\n    total = total + i\n}\n\nint iterations = 0\nwhile iterations < 2\n{\n    iterations = iterations + 1\n}\n\nif value.Sum() == 5 and Add(total, iterations) == 8\n{\n    Console.Log(\"core-edition-ok\")\n}\nelse\n{\n    Console.Log(\"core-edition-failed\")\n}\n","manifest":"package = \"tests.coreEdition.positive\"\n","tags":["cpu","complete-program"],"verification":"type checked","run":"cpu-oracle","source":"tests/compiler/core-edition/positive/start.yh","sha256":"658c24b53e041479c84c3908c77cad8390cdaa6afba4f4bec9d01c3ece22d719","checked":"2026-09-09","diagnostic":"","observedOutput":null,"checkedBackend":null}],"searchTerms":[],"url":"https://demonhunterlabs.com/academy/api?item=word--while","json":"https://demonhunterlabs.com/reference/items/word--while.json","markdown":"https://demonhunterlabs.com/reference/text/word--while.md"}
