default
Sets a default value for any variable with no assigned value. default
will show its value if the input is nil
, false
, or empty.
In this example, product_price
is not defined, so the default value is used.
Input
Output
In this example, product_price
is defined, so the default value is not used.
Input
Output
In this example, product_price
is empty, so the default value is used.
Input
Output
Allowing false
false
To allow variables to return false
instead of the default value, you can use the allow_false
parameter.
Input
Output
Last updated