Conditionals Return Values
Learn how conditional statements return values and how that can be useful.
We'll cover the following
Another extremely useful aspect about if
and unless
statements in Ruby is that they return values.
An if
statement, with all of its branches, evaluates the value returned by the statement that was last evaluated, just like a method does.
Example
For example, take a look at this:
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy