-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KtMap.map(MapEntry<K, V> -> R) : KtList<R> #79
Comments
One way of solving it would be to convert the interop properties to functions called But this would clash with the existing And for loops would look even worse for(final i in listOf(1, 2, 3).asIterable()) {
print(i);
} |
We could keep KtIterable.iter -> Iterable
KtList.asList() -> List
KtMap.asMap() -> Map
KtSet.asSet() -> Set |
On could name the |
|
From other languages I would expect that void main() {
[1, 2, 3, 4, 5]
.map((i) => i * 2)
.forEach(print);
} I would prefer another (new?) naming convention to get the standard Dart objects from the Kt* objects. I would renamed them to I didn't yet understand the problem with for(final i in listOf(1, 2, 3).asIterable()) {
print(i);
} |
Context why |
Okay, thanks for the context. I understand now that the Iterable interface is much bigger than expected.. With this step back, I didn't see a big point why a map method is needed. Esp. mapping over a map is always a little bit tricky. Are the code maps over the key or values or both? Readable code is so important, that I think its also great that KtMap has already the options to map over the keys, values and entries with mapFrom({ "a": 1, "b": 2, "sum": 3 })
.entries
.filter((entry) => entry.key != "sum")
.map((entry) => entry.value)
.map((value) => value * 2)
.forEach(print); Hopefully you will get some other feedback as well. For me, I'm fine with the current version. 😏 |
Kotlin allows mapping of entries in a map using
.map
This leads to a name clash with
KtMap.map
which returns the DartMap
.Currently all kt.dart collections allow access to the dart equivalents.
We have to find a way to provide standardized ways to access the dart equivalents. Additionally we should make it as easy as possible to make kt.dart collections useable using for loops.
The text was updated successfully, but these errors were encountered: