手记

groovy(6)范围

package variable

//定义范围Range 继承于List
def range=1..10
println(range[3])//4
println(range.contains(3))//true
println(range.from)//1
println(range.to)//10
Range range1 //定义
//遍历
range.each {//闭包

println( it)

}
for(i in range){

println(i)

}
def reslt=getGrade(75)
def getGrade(Number number){

def resultswitch (number){    case 0..60:
        result='不及格'
        break
    case 60..<70:
        result='及格'
        break
    case 70..<80:
        result='良好'
        break
    case 80..100:
        result='优秀'
        break}
result  //return 可以不写

}
println(reslt)//良好

原文链接:http://www.apkbus.com/blog-953329-77637.html

0人推荐
随时随地看视频
慕课网APP