List assignment operator support
See original GitHub issueCurrently Sass supports appending to a list, but not setting an element to a list to a new value. The only way to implement this natively is to iterate through the list:
@function set-nth($list, $n, $value)
{
$new_list: ();
@for $i from 1 through max($n, length($list)) {
@if ($i == $n) {
$new_list: append($new_list, $value);
} @else {
@if (length($list) >= $i) {
$new_list: append($new_list, nth($list, $i));
} @else {
$new_list: append($new_list, null);
}
}
}
@return $new_list;
}
This is exceptionally slow, and loading a 3rd party tool to add support for setting elements seems very silly.
set-nth
should be introduced to the core, taking (list, n, value)
and returning a new instance of the modified list.
This is related to #537, but this proposal retains the immutability of lists, creating a function which returns the modified list, in line with append
.
Issue Analytics
- State:
- Created 10 years ago
- Comments:10
Top Results From Across the Web
Assignment Operators in Python - GeeksforGeeks
Here, we will cover Assignment Operators in Python. So, Assignment Operators are used to assigning values to variables.
Read more >Assignment operators - cppreference.com
Concurrency support library (C++11) ... List initialization (C++11) ... Assignment operators modify the value of the object.
Read more >Python Operators - A Quick Reference | DigitalOcean
List of Python Operators · Assignment Operators · Arithmetic Operators · Logical Operators · Comparison Operators · Bitwise Operators ...
Read more >Python Assignment Operators - W3Schools
Operator Example Same As Try it
= x = 5 x = 5 Try it »
+= x += 3 x = x + 3...
Read more >Assignment Operators in C - Tutorialspoint
Assignment Operators in C, The following table lists the assignment operators supported by the C language −
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve made a couple of advanced lists functions too:
There is still a lot of room for improvements, starting with function names. I wasn’t sure how to call them.
Agree. List helpers are super important.