mirror of
https://github.com/danog/sass-site.git
synced 2024-12-02 17:38:26 +01:00
24 lines
942 B
Plaintext
24 lines
942 B
Plaintext
{% markdown %}
|
|
## Truthiness and Falsiness
|
|
|
|
Anywhere `true` or `false` are allowed, you can use other values as well. The
|
|
values `false` and [`null`][] are *falsey*, which means Sass considers them to
|
|
indicate falsehood and cause conditions to fail. Every other value is considered
|
|
*truthy*, so Sass considers them to work like `true` and cause conditions to
|
|
succeed.
|
|
|
|
[`null`]: /documentation/values/null
|
|
|
|
For example, if you want to check if a string contains a space, you can just
|
|
write `string.index($string, " ")`. The [`string.index()` function][] returns
|
|
`null` if the string isn't found and a number otherwise.
|
|
|
|
[`string.index()` function]: /documentation/modules/string#index
|
|
{% endmarkdown %}
|
|
|
|
{% headsUp %}
|
|
Some languages consider more values falsey than just `false` and `null`. Sass
|
|
isn't one of those languages! Empty strings, empty lists, and the number `0` are
|
|
all truthy in Sass.
|
|
{% endheadsUp %}
|