Replace our firstIfSingle extension with singleOrNull from the Kotlin library.
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.core.extensions
|
||||
|
||||
/**
|
||||
* Returns the first element if the list contains exactly one element, otherwise returns null.
|
||||
*/
|
||||
inline fun <reified T> List<T>.firstIfSingle(): T? {
|
||||
return if (size == 1) first() else null
|
||||
}
|
||||
Reference in New Issue
Block a user