You will be given an array and a limit value. You must check that all values in the array are below or equal to the limit value. If they are, return true. Else, return false.
You can assume all values in the array are numbers.
起初我觉得这个还算可以吧
fun smallEnough(a : IntArray, limit : Int) : Boolean {
var result :Boolean = true
a.forEach {
f->if (f > limit){
result=false
}
}
return result
}
直到我提交之后
fun smallEnough(a: IntArray, limit: Int) = a.all { it <= limit }
标签:kata1,return,Kotlin,limit,result,IntArray,false,array
From: https://www.cnblogs.com/ukzq/p/16622574.html