23Manipulating Lists

As well as looping through lists, you can manipulate them by adding new values or joining multiple lists together. Sass provides two functions that can help you with this: join($list1, $list2, [$separator]) and append($list1, $val, [$separator]). Their names are pretty self-explanatory!

join() lets you join together two lists. It simply takes the two lists you pass in, as seen in the example. In that situation, you want to keep the two lists of colors separate for some purposes, but need them to be one large list for others. So, you use join() to merge the two!

append() adds a new item to an existing list. This can help in situations where you need two lists that only have one item that is different. These functions ...

Get Pragmatic Guide to Sass 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.