通过移除测试主题重复,针对范围进行检查使代码更简单。
示例:
fun checkMonth(month: Int): Boolean { return month >= 1 && month <= 12 }
建议通过快速修复将基于比较的检查替换为基于范围的检查:
fun checkMonth(month: Int): Boolean { return month in 1..12 }