小编And*_*ndi的帖子

Kotlin String.toBoolean 替换

由于 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 …
Run Code Online (Sandbox Code Playgroud)

kotlin

4
推荐指数
1
解决办法
4488
查看次数

标签 统计

kotlin ×1