Elixir treats branching as expression-oriented control flow. Classical conditionals remain useful when creating multiclause functions would add unnecessary structure. section 3.0 section 3.3.2
Choose the branching form that matches the decision:
- Use if or unless for a single truthiness test; the selected block’s last expression becomes the return value, and if without else returns nil when false. section 3.3.2
- Use cond for multiple boolean conditions, ordering clauses from most specific to fallback; unmatched conditions raise an error. section 3.3.2
- Use case when branching by patterns, while multiclause functions can replace many conditional forms. section 3.0 section 3.3.2
Status classification
A call-status function can check populated fields in order: return :ended when ended_at exists, :started when started_at exists, and :pending through a final true clause. section 3.3.2
if condition do ... else ... end
Use the compact listing to compare Elixir’s multiline if form with its expression-oriented branching syntax. section 3.3.2




















