What Are Conditionals?

Learn about conditionals in Ruby.

What are conditionals?

Sometimes, we only want to perform an action if a certain criterion is met. Other times, we may want to check for a certain condition and then do one thing or another based on the answer. If this is true, then do that. Otherwise, do something else.

All practical programming languages have some way of expressing this, and in Ruby, it looks like this:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy