mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2026-11-29 18:37:18 +08:00
* refactor: clean to roadmap content * refactor: move shared helpers into scripts/lib
9 lines
857 B
Markdown
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) |