RUBY: Case expression

Source: Internet
Author: User
Tags case statement

There are two forms of Ruby case expressions:

The first form is similar to a set of continuous if statements: it allows you to list a set of conditions and execute the first statement corresponding to the true condition expression.

In the second form, specify a target at the top of the case statement, and each when clause lists one or more comparison conditions.

 

  • Like if, case returns the value of the last expression to be executed. If the expression and condition are in the same row, the then keyword can be used to differentiate them.

 

RUBY: Case expression

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.