last-index ()
Returns the last index at which a specified item can be found in a list; otherwise, 0 is returned, indicating the item is not present. The list is searched backwards, starting at a given index when specified.
Parameters
$list
- The list from which the value is to be located.
- Type
List
$value
- The value to locate in the list.
- Type
*
$start-at
- The index at which to begin the search. A negative index can be used, indicating an offset from the end of the source string.
- Type
Number
- Default
-1
Return Value
Number
- The index of the last occurrence of the value; otherwise,
0
.
Example
@use '@sass-fairy/list';
$list: 32 8 65 79 34 8 13 66 18;
// 1. Get the last index of `8`
@debug list.last-index($list, 8);
// 7
// 2. Get the last index of `8` starting a specific index
@debug list.last-index($list, 34, -6);
// 2