> For the complete documentation index, see [llms.txt](https://ploegert.gitbook.io/til/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ploegert.gitbook.io/til/programmy/ruby/use-a-case-statement-as-a-cond-statement.md).

# Use A Case Statement As A Cond Statement

Many languages come with a feature that usually takes the name *cond statement*. It is essentially another way of writing an *if-elsif-else* statement. The first conditional in the *cond statement* to evaluate to true will then have its block evaluated.

Ruby doesn't have a *cond statement*, but it does have a *case statement*. By using a *case statement* with no arguments, we get a *cond statement*. If we exclude arguments and then put arbitrary conditional statements after the `when` keywords, we get a construct that acts like a *cond statement*. Check out the following example:

```ruby
some_string = "What"

case
when some_string.downcase == some_string
  puts "The string is all lowercase."
when some_string.upcase == some_string
  puts "The string is all uppercase."
else
  puts "The string is mixed case."
end

#=> The string is mixed case.
```

[source](http://www.skorks.com/2009/08/how-a-ruby-case-statement-works-and-what-you-can-do-with-it/)
