| 16 | Controlling Flow with @if |
You can make your mixins even more powerful by making certain things happen only under specific circumstances. You do this using @if. This gating mechanism, also known as a conditional statement, is a common feature of programming languages, so you might be familiar with it.
To start your statement, you write the @if keyword. After that, you put a statement that will evaluate to true or false. For example, 20 > 10 would evaluate to true. And, "hello" == "world" would evaluate to false. Other common comparators are available, such as == (equal to), != (not equal to), > (greater than), and < (less than).
If the statement is true, whatever is inside the following declaration block will be executed. If the statement ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access