Skip to content

Commit 2a59e6a

Browse files
author
Marco Romano
authored
Properly inline tryOrNull() (#1003)
Nullable params can't be inlined, default empty lambdas are therefore preferred.
1 parent 784b84d commit 2a59e6a

File tree

1 file changed

+2
-2
lines changed
  • libraries/core/src/main/kotlin/io/element/android/libraries/core/data

1 file changed

+2
-2
lines changed

libraries/core/src/main/kotlin/io/element/android/libraries/core/data/Try.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
package io.element.android.libraries.core.data
1818

19-
inline fun <A> tryOrNull(noinline onError: ((Throwable) -> Unit)? = null, operation: () -> A): A? {
19+
inline fun <A> tryOrNull(onError: ((Throwable) -> Unit) = { }, operation: () -> A): A? {
2020
return try {
2121
operation()
2222
} catch (any: Throwable) {
23-
onError?.invoke(any)
23+
onError.invoke(any)
2424
null
2525
}
2626
}

0 commit comments

Comments
 (0)