Kotlin编程Android技术知识程序员

kotlin 基础 7 默认参数和具名参数

2019-04-05  本文已影响4人  zidea
kotlin.jpeg
fun calRectArea(width:Float,length:Float):Float{
    return width * length

}

fun calCircleArea(PI:Float,radius:Float):Float{
    return 2 * PI * radius
}

fun colcumVolumn(PI:Float,radius: Float,height:Float):Float{
    return PI * radius * radius * height
}

fun ballSurface(PI: Float,radius: Float):Float{
    return PI * radius * radius * 4
}
val pi = 3.1415926f
fun calCircleArea(PI:Float = pi,radius:Float):Float{
    return 2 * PI * radius
}
println(calCircleArea(radius = 2.0f))
上一篇 下一篇

猜你喜欢

热点阅读