set-nth ()
Returns a list with the value at the given index replaced with the specified value.
Parameters
$list
- The list from which the value is to be replaced.
- Type
List
$index
- The index at which the value is to be replaced. A negative index can be used, indicating an offset from the end of the list.
- Type
Number
$value
- The value which is to be replaced.
- Type
*
$separator
- The type of separator to be used by the copied list.
- Type
space | comma | slash | auto
- Default
auto
Return Value
List
- A list with the given value at the given index.
Example
@use '@sass-fairy/list';
$list: 'ant', 'bison', 'camel', 'bison', 'duck', 'elephant';
@debug list.set-nth($list, -2, 'chicken');
// 'ant', 'bison', 'camel', 'bison', 'chicken', 'elephant'