package Stage3fun main() {println(checkPermission("root","123"))
}//检查校验
//username.takeif{true/false} true:返回username本身 false:返回nullfun checkPermission(userame:String,pwd:String):String{return userame.takeIf { permissionSystem(userame,pwd) }?:"你没有权限"
}//权限系统
private fun permissionSystem(userame:String,pwd:String):Boolean{return if(userame=="root" && pwd=="123") true else false
}
执行结果