You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current naming is confusing
In stdlib removeAll/retainAll modify collections in place, while filter/filterNot return new ones.
In kotlinx.collections.immutable removeAll/retainAll return ones and filter/filterNot are taken from stdlib, so they do the same.
This also relates to #123, where persistentList.filter { it % 2 == 0 }.toPersistentList() could be written as persistentList.retainAll { it % 2 == 0 } but the letter is less intuitive when one is used to stdlib.
The text was updated successfully, but these errors were encountered:
I think one issue here is that filter/filterNot() in the stdlib are extension functions, while the removeAll/retainAll() in the immutable library are member functions that I think are meant to have the same names as the stdlib's MutableCollection functions?
Although I'm not sure where PersistentCollection.removeAll(predicate: (E) -> Boolean) fits into all this, as that is not something from MutableCollection, but instead seems more like the stdlib's MutableIterable<T>.removeAll(predicate: (T) -> Boolean) extension function.
Thank for your feedback!
A similar issue is discussed here: #8
We are aware of the possible confusion, but we have not yet found a satisfactory naming scheme. In the future, we will definitely seek to address this issue.
Current naming is confusing
In stdlib removeAll/retainAll modify collections in place, while filter/filterNot return new ones.
In kotlinx.collections.immutable removeAll/retainAll return ones and filter/filterNot are taken from stdlib, so they do the same.
This also relates to #123, where
persistentList.filter { it % 2 == 0 }.toPersistentList()
could be written aspersistentList.retainAll { it % 2 == 0 }
but the letter is less intuitive when one is used to stdlib.The text was updated successfully, but these errors were encountered: