File tree 1 file changed +4
-5
lines changed
kotlinx-coroutines-core/common/src/flow/terminal
1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,6 @@ public suspend fun <T: Any> Flow<T>.singleOrNull(): T? {
77
77
if (result != null ) error(" Expected only one element" )
78
78
result = value
79
79
}
80
-
81
80
return result
82
81
}
83
82
@@ -126,7 +125,7 @@ public suspend fun <T> Flow<T>.first(predicate: suspend (T) -> Boolean): T {
126
125
* Returns `null` if the flow was empty.
127
126
*/
128
127
public suspend fun <T : Any > Flow<T>.firstOrNull (): T ? {
129
- var result: Any? = NULL
128
+ var result: Any? = null
130
129
try {
131
130
collect { value ->
132
131
result = value
@@ -135,15 +134,15 @@ public suspend fun <T : Any> Flow<T>.firstOrNull(): T? {
135
134
} catch (e: AbortFlowException ) {
136
135
// Do nothing
137
136
}
138
- return result.takeUnless { it == = NULL } as T ?
137
+ return result.takeUnless { it == = null } as T ?
139
138
}
140
139
141
140
/* *
142
141
* The terminal operator that returns the first element emitted by the flow matching the given [predicate] and then cancels flow's collection.
143
142
* Returns `null` if the flow did not contain an element matching the [predicate].
144
143
*/
145
144
public suspend fun <T : Any > Flow<T>.firstOrNull (predicate : suspend (T ) -> Boolean ): T ? {
146
- var result: Any? = NULL
145
+ var result: Any? = null
147
146
try {
148
147
collect { value ->
149
148
if (predicate(value)) {
@@ -154,5 +153,5 @@ public suspend fun <T : Any> Flow<T>.firstOrNull(predicate: suspend (T) -> Boole
154
153
} catch (e: AbortFlowException ) {
155
154
// Do nothing
156
155
}
157
- return result.takeUnless { it == = NULL } as T ?
156
+ return result.takeUnless { it == = null } as T ?
158
157
}
You can’t perform that action at this time.
0 commit comments