sass-site/source/documentation/snippets/_truthiness-and-falsiness.erb
Natalie Weizenbaum 029520349a Rename /documentation/functions to /documentation/modules
This hierarchy is now going to document built-in modules, which mostly
contain functions but can also contain mixins and may potentially
contain variables in the future.
2019-09-04 15:24:22 -07:00

22 lines
875 B
Plaintext

## 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 `index($string, " ")`. The [`str-index()` function][] returns `null` if
the string isn't found and a number otherwise.
[`str-index()` function]: /documentation/modules/string#str-index
<% heads_up do %>
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.
<% end %>