Level of Difficulty: Beginner.
Have you ever wanted to assign a variable based on the value of another variable but… Without the use of an IF statement block? Here’s how to achieve that.
Let’s take an example… We have a boolean variable, named UnicornsExist which can be set by the user through an input dialog. Based on the value of UnicornsExist, we will print either “This is optimal” if the value is true or “This is not optimal” if the value is false.
Your sequence should look something like this:
The syntax of the shorthand if statement is as follows:
IF (<Condition>, <When True>, <When False>)
So in the context of the example outlined above, the if statement would be the following:
IF (UnicornsExist, "This is optimal", "This is not optimal")
The code to this solution is available on GitHub, here.