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.

Proper arrays in Stylus

See original GitHub issue

Now we have hashes and it seems obvious that we need a support or proper arrays.

Stylus already have lists, but they’re not the best fit for the job.

There are already a lot of problems with the usage of the lists as arrays, and fixing some of them would break the backwards compatibility, as some of the bugs could be misused as features for a long time.

So, I think it would make sense to create a new data type — Array.

I wonder if I should explain the details of implementation here, as it could would the same arrays work in other languages like js:

foo = [10px, 20px, 40px]

foo[1]

// => 20px

The only conflicts I can see are with attribute selectors and cases when we have an array consisting of the only number, like [10]: but they all seem to be handable.

Issue Analytics

  • State:open
  • Created 10 years ago
  • Reactions:6
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
itsezccommented, Sep 25, 2018

Still waiting on this, such a useful feature

2reactions
Panyacommented, Aug 6, 2015

@FranzSkuffka which version of Stylus have you used? You can use push function (it should work in 0.52.0):

someArray = ('hey')
push(someArray, 'yo')

body
  test: someArray[0] // 'hey'
  test: someArray[1] // 'yo'
Read more comments on GitHub >

github_iconTop Results From Across the Web

Add value to array in stylus lang css - Stack Overflow
I have 2 arrays. In another expression, in another mediaquery, how do I pull values ​​from one array and insert them into another?...
Read more >
Using arrays in experiment code - PsyToolkit
Sometimes, it is good to store a whole sequence of numbers. ... Arrays are also variables, but instead of storing just one number...
Read more >
Chapter 8: Introducing One-Dimensional Arrays
One-dimensional arrays (also known as lists) are the fundamental data structure that allows a program to store many elements of data, using a...
Read more >
8. Variables, Constants, and Arrays - FORTH, Inc.
In Forth, variables are appropriate for any value that is used inside a definition that may need to change at any time after...
Read more >
Check if an array can be Arranged in Left or Right Positioned ...
An efficient solution for this problem needs little bit observation and pen-paper work. To satisfy the Left or Right Positioned Array ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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