Three things you should know about lists
Here are three important things you should know about lists:
- Sass list indexes DO NOT start at zero
- You can separate the items in a list with spaces instead of commas
- You can even leave out parentheses
Let's dive deep in the preceding mentioned points.
Sass list indexes do not start at zero. Some of you who've dealt with arrays in most languages will be expecting to get a value of $h3-font-size
with the preceding code. However, Sass lists are not 0 based. Their first index is, in fact 1, meaning we can use the number that makes sense (to people who don't do a lot of programming) and not be required to subtract 1 from our heading variable first.
You can separate the items in a list with spaces instead of commas. This is means we could have written our list like this instead:
$headings: ($h1-font-size $h2-font-size $h3-font-size $h4-font-size, $h5-font-size $h6-font-size);
One thing to be very careful of when using space...