question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add the index iteration variable to @each

See original GitHub issue

Whenever i do:

@for $i from 1 through length($colors)
  $color: nth($colors, $i)
  .column:nth-child(#{$i})
    background-color: $color

i feel like a kitten dies somewhere in misery and loneliness. And i find myself doing that in almost any project, so that’s quite a lot of kittens. 😦

I wish i could do this instead:

@each $color, $index in $colors
  .column:nth-child(#{$index})
    background-color: $color

Please spare the kittens. It’s our war, not theirs.

Issue Analytics

  • State:open
  • Created 10 years ago
  • Reactions:6
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
yairEOcommented, Apr 5, 2018

is this still relevant ?

update: it’s November 2016, whats up? I’m practically sitting and waiting for this 😕

1reaction
bstrilziwcommented, Apr 5, 2018

I really would love an index interator variable, too. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Accessing the index in 'for' loops - python - Stack Overflow
The fastest way to access indexes of list within loop in Python 3.7 is to use the enumerate method for small, medium and...
Read more >
Looping with indexes - Python Morsels
We start n at 1 and we're incrementing it by 1 in each iteration of our loop. Using range of len (not recommended)....
Read more >
Indexing and Iteration - CMU Statistics
There are 3 ways to index a vector, matrix, data frame, or list in R: ... We pass a variable to select on,...
Read more >
How to use an index variable with C#'s foreach loop?
A quick way to use an index variable with foreach is to declare one before the loop starts. And then inside the loop...
Read more >
Python - Access Index in For Loop With Examples
Using index variable to access the items of the list in order of 0 to 3, where 0 is the default index and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found