Comments (11)
The same method seems wrong at first glance. Here's what it needs to do:
same will return true only if the lists internals are the same instances (comparing by identity). This will be fast even for very large lists, since it doesn't compare each item. Note: This is not the same as identical(list1, list2) since it doesn't compare the lists themselves, but their internal state. Comparing the internal state is better, because it will return true more often.
This means that IList.empty().same(IList.empty())
should return true, but I'm not sure it does. Could you please add this test and fix this? Thanks.
from fast_immutable_collections.
No problem. This package is very complex, as you probably noticed. The best way to guarantee everything works is adding as many tests as you can. Don't worry if some tests are redundant, just add as many as you think are necessary for you to feel confident it's working.
from fast_immutable_collections.
I started to implement some tests, so that it wont happen again. Please let me know if I forgot to test something @marcglasberg
from fast_immutable_collections.
I've just tried the proposed solution in the flutter app where i initially discovered the error. With the IListEmpty type everything is working as expected
from fast_immutable_collections.
Also, won't you also have to do this for ISet.empty()
and iMap.empty()
?
from fast_immutable_collections.
Yes of course, i just wanted to propose my solution to you first before continuing
from fast_immutable_collections.
I've addeded the test and the fix in this commit: f5cc545
Will do the other collections now
from fast_immutable_collections.
I think you are missing the point of the same method. It's supposed to compare the internals. But don't worry, I will fix this later after I merge the PR.
from fast_immutable_collections.
Yes that is probably true, i have no idea what comparing the internals should look like on a empty type where there is no real internal list.
from fast_immutable_collections.
Fixed with #76
from fast_immutable_collections.
I've just improved the same
method and published a new version to pub.dev.
from fast_immutable_collections.
Related Issues (20)
- Resolve warnings pointed out by dart analyzer HOT 9
- Use of Fast Immutable Collections with Freezed results in dynamic types HOT 4
- Use unsafe immutable collections for JSON parsing HOT 4
- Const constructors? HOT 1
- Add `firstWhereOrNull` method HOT 1
- Incompatible with json_serializable toJson/fromJson: issue _safeKeyFromJson HOT 4
- Can Tuple2 be removed with Dart 3.0 now having Records? HOT 5
- IListConst when empty has not type HOT 3
- Suggestion: Use `@useResult` instead of `@useCopy` (or use both) HOT 1
- IHashMap Implementation HOT 3
- What is the most straightforward way to replace an item on an ISet? HOT 1
- IList `replaceFirstWhere` unnecessary nullable HOT 4
- Best Practices for Mutating Collections Multiple Times HOT 1
- Sliding
- ISet.difference does not always return the correct result HOT 1
- IMap update throw "Null check operator used on a null value" HOT 1
- [QUESTION] About IMap.update HOT 4
- Docs error? HOT 2
- Growable ListMap, with `insert` method. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fast_immutable_collections.