Files
developer-roadmap/roadmaps/ruby/content/case@BiUeOOd9E7V4Gpmu3PWj7.md
Arik Chakma 274082fd77 feat: clean roadmap content and sync scripts (#10181)
* refactor: clean to roadmap content

* refactor: move shared helpers into scripts/lib
2026-07-28 05:45:17 +06:00

9 lines
857 B
Markdown

# Case Statements
A `case` statement in Ruby provides a way to execute different blocks of code based on the value of a variable or expression. It's an alternative to using multiple `if/elsif/else` statements, especially when you need to check for several different possible values. The `case` statement compares a given value against multiple `when` clauses, and executes the code block associated with the first matching clause. An optional `else` clause can be included to handle cases where none of the `when` clauses match.
Visit the following resources to learn more:
- [@article@Case statements](https://www.theodinproject.com/lessons/ruby-conditional-logic#case-statements)
- [@article@The Many Uses Of Ruby Case Statements](https://www.rubyguides.com/2015/10/ruby-case/)
- [@video@case..when in Ruby](https://www.youtube.com/watch?v=gsmexAC2eoM)