list.first()
The list.first()
function returns the first element of $list
.
// Sass.
@use 'sass:list';
// The `list.first()` function.
@function first($list) {
@return if(type-of($list) == list, list.nth($list, 1), $list);
}
https://github.com/angular-package/sass/blob/main/list/_list.first.function.scss
// Sass.
@use 'sass:list';
// Status: DONE
// The `list.first()` function returns the first element of `$list`.
// @param `$list` The list to get the first element from.
// @return The return value is the first element of `$list`.
@function first($list) {
@return if(type-of($list) == list, list.nth($list, 1), $list);
}
// Examples.
// @debug first(('a', 'b', c, d, 2, 4, 5, (a: 1))); // a
// @debug first(((a: 1), 'b', c, d, 2, 4, 5, (a: 1))); // (a: 1)
Parameters
$list
$list
The list to get the first element from.
Return
The return value is the first element of $list
.
Examples
// Use.
@use 'angular-package/sass/list';
// Examples.
@debug list.first(('a', 'b', c, d, 2, 4, 5, (a: 1))); // ()
@debug list.first(((a: 1), 'b', c, d, 2, 4, 5, (a: 1))); // ((a: 1),)
Last updated
Was this helpful?