Deprecate mapNotNull to change its behavior later.
#KT-4410
This commit is contained in:
@@ -6728,6 +6728,7 @@ public inline fun <R, C : MutableCollection<in R>> ShortArray.mapIndexedTo(desti
|
||||
/**
|
||||
* Returns a list containing the results of applying the given [transform] function to each non-null element of the original collection.
|
||||
*/
|
||||
@Deprecated("This function will change its semantics soon to map&filter rather than filter&map. Use filterNotNull().map {} instead.", ReplaceWith("filterNotNull().map(transform)"))
|
||||
public inline fun <T : Any, R> Array<out T?>.mapNotNull(transform: (T) -> R): List<R> {
|
||||
return mapNotNullTo(ArrayList<R>(), transform)
|
||||
}
|
||||
@@ -6736,6 +6737,7 @@ public inline fun <T : Any, R> Array<out T?>.mapNotNull(transform: (T) -> R): Li
|
||||
* Appends transformed non-null elements of original collection using the given [transform] function
|
||||
* to the given [destination].
|
||||
*/
|
||||
@Deprecated("This function will change its semantics soon to map&filter rather than filter&map. Use filterNotNull().mapTo(destination) {} instead.", ReplaceWith("filterNotNull().mapTo(destination, transform)"))
|
||||
public inline fun <T : Any, R, C : MutableCollection<in R>> Array<out T?>.mapNotNullTo(destination: C, transform: (T) -> R): C {
|
||||
for (element in this) {
|
||||
if (element != null) {
|
||||
|
||||
@@ -1080,6 +1080,7 @@ public inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(d
|
||||
/**
|
||||
* Returns a list containing the results of applying the given [transform] function to each non-null element of the original collection.
|
||||
*/
|
||||
@Deprecated("This function will change its semantics soon to map&filter rather than filter&map. Use filterNotNull().map {} instead.", ReplaceWith("filterNotNull().map(transform)"))
|
||||
public inline fun <T : Any, R> Iterable<T?>.mapNotNull(transform: (T) -> R): List<R> {
|
||||
return mapNotNullTo(ArrayList<R>(), transform)
|
||||
}
|
||||
@@ -1088,6 +1089,7 @@ public inline fun <T : Any, R> Iterable<T?>.mapNotNull(transform: (T) -> R): Lis
|
||||
* Appends transformed non-null elements of original collection using the given [transform] function
|
||||
* to the given [destination].
|
||||
*/
|
||||
@Deprecated("This function will change its semantics soon to map&filter rather than filter&map. Use filterNotNull().mapTo(destination) {} instead.", ReplaceWith("filterNotNull().mapTo(destination, transform)"))
|
||||
public inline fun <T : Any, R, C : MutableCollection<in R>> Iterable<T?>.mapNotNullTo(destination: C, transform: (T) -> R): C {
|
||||
for (element in this) {
|
||||
if (element != null) {
|
||||
|
||||
@@ -565,6 +565,7 @@ public inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.mapIndexedTo(d
|
||||
/**
|
||||
* Returns a sequence containing the results of applying the given [transform] function to each non-null element of the original sequence.
|
||||
*/
|
||||
@Deprecated("This function will change its semantics soon to map&filter rather than filter&map. Use filterNotNull().map {} instead.", ReplaceWith("filterNotNull().map(transform)"))
|
||||
public fun <T : Any, R> Sequence<T?>.mapNotNull(transform: (T) -> R): Sequence<R> {
|
||||
return TransformingSequence(FilteringSequence(this, false, { it == null }) as Sequence<T>, transform)
|
||||
}
|
||||
@@ -573,6 +574,7 @@ public fun <T : Any, R> Sequence<T?>.mapNotNull(transform: (T) -> R): Sequence<R
|
||||
* Appends transformed non-null elements of original collection using the given [transform] function
|
||||
* to the given [destination].
|
||||
*/
|
||||
@Deprecated("This function will change its semantics soon to map&filter rather than filter&map. Use filterNotNull().mapTo(destination) {} instead.", ReplaceWith("filterNotNull().mapTo(destination, transform)"))
|
||||
public inline fun <T : Any, R, C : MutableCollection<in R>> Sequence<T?>.mapNotNullTo(destination: C, transform: (T) -> R): C {
|
||||
for (element in this) {
|
||||
if (element != null) {
|
||||
|
||||
Reference in New Issue
Block a user