Statements and Control Flow
Klyn uses indentation-defined blocks and a compact statement vocabulary. This page covers the control-flow statements you will use constantly in real code.
count = 10
name as String = "Ada"
count += 1
count--
Assignment updates an existing variable while preserving its established type.
score = 72
if score >= 90:
print("excellent")
elif score >= 50:
print("pass")
else:
print("retry")
i = 0
while i < 3:
print(i)
i += 1
Use while when the continuation condition depends on values updated in the body.
for i = 0 to 5:
print(i)
Both bounds are inclusive. The example prints 0 through 5.
When iterating over indices, use an explicit upper bound such as
values.size - 1.
for value in [10, 20, 30]:
print(value)
config = {"theme": "dark", "fullscreen": true}
for key in config:
print(key)
for pair in config.items():
print(pair)
Iterating directly over a map yields keys. Use keys(), values(), or
items() when you want a specific view.
while true:
text = input("> ")
if text == "":
continue
if text == "quit":
break
print(text)
assert count > 0
if featurePending:
pass
assert is appropriate for invariants and tests. pass is an explicit
placeholder that leaves a block intentionally empty.