Welcome to CodeCrew Infotech
We learn basic conditional statements and here we explore some different examples of conditional statements.
Here "Contains" is the one type of Operator.
In this example remove the case sensitivity. Here downcase is the filter we learn more about it soon
In this type of example, you can use contains to search items within an array of strings.
Another helpful method is the unless operator. This operator runs code when a statement is false.
The switch statement is also known as a multi-choice or multi-decision statement.
Writing the code using the multiple if..else becomes lengthy and also difficult to manage. Using a switch statement is done by easy.
It provides the choice for each value of variable or expression.
The switch statement tests the value of a given variable against a list of case values and when the match is found, a statement associated with the case is executed.
The switch..case statement is executed in the following order:
the value of the expression is compared against the value of the case label.
if the case is found whose value matches the value of the expression, then the statement associated with the case is executed. there is a single statement or multiple statements. There is a break that sends the control to the next statement.
if the value of the expression does not match with any case value then the statement associated with the default case is executed.