-
Notifications
You must be signed in to change notification settings - Fork 63
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
Add orEmpty extensions for immutable collections #183
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about PersistentList.orEmpty: PersistentList
, PersistentMap.orEmpty: PersistentMap
and PersistentSet.orEmpty: PersistentSet
overloads 🙏 ?
|
But when we need a value of |
Seems we can return |
The change of return type to Persistent is inefficient. For example, if the list is ImmutableList, but is not PersistentList, orEmpty will convert it to PersistentList, it is inefficient. The better way is having two overloads, that avoids unnecessary operations. |
I didn't take kotlinx.collections.immutable/core/commonMain/src/extensions.kt Lines 513 to 570 in 1d18389
|
d9aabf8
to
86df216
Compare
Closes #182.