-
Notifications
You must be signed in to change notification settings - Fork 30
Replace Option<T>
with ?
in ListK
(part 1)
#196
Conversation
Oh, that sucks :( This should be fixable with |
…isting type inference
Option<T>
with ?
in ListK
(part 1)
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.
* } | ||
* ``` | ||
*/ | ||
fun <B> filterNullMap(f: (A) -> B?): ListK<B> = |
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.
Should we do? We're also trying to algining more to the names familiar in Kotlin from the std. IIRC there is 2 Iterable
extensions for the signature in the std. filterMap
and mapNotNull
?
@JvmName("mapNotNull")
fun <B> filterMap(f: (A) -> B?): ListK<B>
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.
I think as long as the stdlib ones don't have any obvious drawbacks we shouldn't have duplicates names and signatures.
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.
In that case I think we should name it mapNotNull
as Kotlin's Std?
We can re-introduce filterMap
if we want later on.
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.
👍
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.
I think filterNullMap
should renamed to mapNotNull
to be inline with Kotlin's Std.
Thanks for the contribution @tapegram! 🙌 🎉
* } | ||
* ``` | ||
*/ | ||
fun <B> filterNullMap(f: (A) -> B?): ListK<B> = |
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.
In that case I think we should name it mapNotNull
as Kotlin's Std?
We can re-introduce filterMap
if we want later on.
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.
Just some nits, overall looks good!
Co-authored-by: Alberto Ballano <aballano@users.noreply.github.com>
Co-authored-by: Alberto Ballano <aballano@users.noreply.github.com>
Co-authored-by: Alberto Ballano <aballano@users.noreply.github.com>
Thanks so much @tapegram for the contribution! |
Part 1 of providing alternatives for fns that use
Option
forListK
.Ran into https://discuss.kotlinlang.org/t/overloaded-function-with-lambda-parameter-of-different-return-types/6053/2 when creating a nullable version of
filterMap
, so I gave the nullable one a different and less good name :(Would especial appreciate any feedback on the naming of these functions, since the older
Option
based functions already have the good names and the type system struggles to handle overloading with generics or lambdas without requiring explicit typing by the consumer, so I had to make up new names when required.