March 2019
Intermediate to advanced
412 pages
9h 49m
English
if statements can be used inside of inline expressions. This can be useful in some scenarios where additional new lines are not desired. Let's construct a scenario where we need to define an API as either cinder or cinderv2, as shown in the following code:
API = cinder{{ 'v2' if api.v2 else '' }}
This example assumes that api.v2 is defined as Boolean True or False. Inline if expressions follow the syntax of <do something> if <conditional is true> else <do something else>. In an inline if expression, there is an implied else; however, that implied else is meant to be evaluated as an undefined object, which will normally create an error. We protect against this by defining an explicit else, which renders a zero-length string. ...
Read now
Unlock full access