# Conditions & Match | EasyNet Docs Source: https://easynet.run/docs/aal/control-flow # Conditions & Match Turn inputs into explicit decisions. if chooses a branch from a Boolean condition. An if ... then ... else ... expression needs both results. match selects the first matching arm in source order. ## Complete example Save the example as control-flow.aal control-flow.aal ``` agent Tutorial is Agent public ability run(score: Int) -> String effects() require score >= 0, "Score must be nonnegative" grade = if score >= 6 then "ready" else "revise" return match grade "ready" -> "Publish" _ -> "Review again" ``` [Download .aal](data:text/plain;charset=utf-8,agent%20Tutorial%20is%20Agent%0A%20%20public%0A%20%20%20%20ability%20run(score%3A%20Int)%20-%3E%20String%20effects()%0A%20%20%20%20%20%20require%20score%20%3E%3D%200%2C%20%22Score%20must%20be%20nonnegative%22%0A%20%20%20%20%20%20grade%20%3D%20if%20score%20%3E%3D%206%20then%20%22ready%22%20else%20%22revise%22%0A%20%20%20%20%20%20return%20match%20grade%0A%20%20%20%20%20%20%20%20%22ready%22%20-%3E%20%22Publish%22%0A%20%20%20%20%20%20%20%20_%20-%3E%20%22Review%20again%22%0A) ## Syntax explained Use ==, !=, <, <=, >, >=, in and not in. Comparisons may chain: 40 <= area < 100. Combine conditions with and or or. require condition, "message" fails with E_REQUIREMENT when false. Place it before the operation it protects. match supports literals, nullary enums, None and bindings. Put the _ catch-all last. Destructuring patterns are not supported. ## Build and run Terminal ``` cargo run --locked --bin aalc -- check control-flow.aal cargo run --locked --bin aalc -- build control-flow.aal -o control-flow.aalc cargo run --locked --bin aalc -- run control-flow.aalc \ --agent Tutorial --ability run \ --args '{"score":7}' \ --state-dir .aal-tutorial/control-flow --invocation control-flow-1 ``` Run with a fresh state directory. The returned value is shown below; the CLI also prints execution information. Expected result ``` "Publish" ``` ## Try it yourself Try score 3 to get Review again, then -1 to trigger require before grade is computed. Use a new invocation ID for each request. [Language source and specification](https://github.com/Brain-Cell-Coding/Agent-Assembly-Language/blob/main/docs/match-patterns.md)