# 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/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ploegert.gitbook.io/til/programmy/ruby/use-a-case-statement-as-a-cond-statement.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
