Cairo Control Flow
Overview
Explain Cairo conditional logic and loops with correct syntax and typing rules.
Quick Use
- •Read
references/control-flow.mdbefore answering. - •Show short examples of
ifexpressions and each loop type (loop,while,for). - •Emphasize that
ifconditions must bebooland thatloopcan return a value withbreak.
Response Checklist
- •Ensure
ifconditions are boolean and branches return the same type when used as an expression. - •Pick the right loop:
loopfor indefinite repetition,whilefor condition-based,forfor ranges/iterators. - •Mention
break/continueandbreak valuewhen returning from a loop.
Example Requests
- •"Why can't I use an integer as an if condition in Cairo?"
- •"How do I return a value from a loop?"
- •"How do I write a for loop over a range?"