由于 Kotlin 1.4 String.toBoolean() 已被弃用,且未记录替代方案。我们现在应该使用java.lang.Boolean.parseBoolean
它还是有 Kotlin 方法来替代它?
/**
* Returns `true` if the content of this string is equal to the word "true", ignoring case, and `false` otherwise.
*/
@Deprecated("Use Kotlin compiler 1.4 to avoid deprecation warning.")
@DeprecatedSinceKotlin(hiddenSince = "1.4")
@kotlin.internal.InlineOnly
public actual inline fun String.toBoolean(): Boolean = this.toBoolean()
/**
* Returns `true` if this string is not `null` and its content is equal to the word "true", ignoring case, and `false` otherwise.
*/
@JvmName("toBooleanNullable")
@SinceKotlin("1.4")
@kotlin.internal.InlineOnly
public actual inline fun String?.toBoolean(): Boolean = java.lang.Boolean.parseBoolean(this)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4488 次 |
最近记录: |