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.

Sum expression in array element becomes array concatenation

See original GitHub issue

Steps to reproduce

PS C:\windows\system32> @(1,2+3).length
3

Expected behavior

PS C:\windows\system32> @(1,2+3).length
2

Actual behavior

PS C:\windows\system32> @(1,2+3).length
3

Environment data


Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jhoneillcommented, Feb 26, 2021

For clarity: the + operator is lower precedence than the , operator
so 1 , 2 + 3 , 4 , 5 reads as (1 , 2) + (3 , 4 , 5) not as 1 , (2 + 3) , 4 , 5

0reactions
ironymancommented, Mar 1, 2021

Oh I suppose that makes sense. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sum of the first M elements of Array formed by infinitely ...
Sum of the first M elements of Array formed by infinitely concatenating given array ; Input: arr[] = {1, 2, 3}, M =...
Read more >
Add not Concatenate Objects in Array - javascript
I am trying to GET total order prices (in USD) in an object array and sum the total. Instead of summing the array,...
Read more >
Sum of array elements - MATLAB sum
This MATLAB function returns the sum of the elements of A along the first array dimension whose size is greater than 1.
Read more >
Array.prototype.reduce() - JavaScript - MDN Web Docs
A function to execute for each element in the array. Its return value becomes the value of the accumulator parameter on the next...
Read more >
Work with arrays | BigQuery
With GoogleSQL, you can construct array literals, build arrays from subqueries using the ARRAY function, and aggregate values into an array using the...
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