true
或 false
常量文字条件且可以简化的 if
表达式。
虽然偶尔是有意为之,但此结构令人困惑,并且通常是由拼写错误或之前的重构所致。
示例:
fun example() {
if (true) {
throw IllegalStateException("Unexpected state")
}
}
该快速修复会移除 if
条件:
fun example() {
throw IllegalStateException("Unexpected state")
}