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.

Easy way to compare arrays?

See original GitHub issue

I tried

const array: f64[] = [20.0,30.0,0,0,0,0]
expect<f64[]>(array).toBe([20.0,30.0,0,0,0,0])

which may not even be the same types of array, but I realized that this compares them by reference (obviously it would fail).

Is there an API to easily compare arrays? Or should I loop on the indexes and use expect on each value for now?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
jtennercommented, Jun 8, 2019

I haven’t closed this issue because I want to enable array of references comparisons.

Since we cannot get the programmatic offset of the child type, we cannot use memcompare because we need the size of the block. We can only opt into block comparisons for strings and array buffers and access their size at runtime. This will be supported in the 1.1.0 release.

Once typeof support exists in the compiler, we will enable regular reference comparisons.

In 1.1.0 they will default to == comparisons, which can be overridden using @operator("=="). This does not help people who want to use portable code, but aspect is burgeoning and I don’t mind enabling support for this later.

0reactions
trusktrcommented, Jun 13, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to compare arrays in JavaScript? - Stack Overflow
To compare arrays, loop through them and compare every value: Comparing arrays: // Warn if overriding existing method if(Array.prototype.equals) ...
Read more >
Compare Two Arrays in Java - GeeksforGeeks
A simple way is to run a loop and compare elements one by one. Java provides a direct method Arrays.equals() to compare two...
Read more >
Comparing Arrays in JavaScript - freeCodeCamp
A better approach would be to compare the array's length and then loop through and compare each element of the array. Method 1:...
Read more >
How do I compare two arrays in JavaScript?
Learn how you can compare two arrays in JavaScript using various different techniques.
Read more >
How to compare two arrays in Java? - Tutorialspoint
Using Arrays.equals(array1, array2) methods − This method iterates over each value of an array and compare using equals method.
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