fun streamlinedFun0(x: Double, y: Double): Double { return x / y } fun main() { println(streamlinedFun0(10.0, 3.0)) }
fun streamlinedFun1(x: Double, y: Double): Double = x / y // = とは、「{ } と return が、変身した」 と、考える. fun main() { println(streamlinedFun1(10.0, 3.0)) }
fun streamlinedFun2(x: Double, y: Double) = x / y // : Double(返す型)を、省略している/型推量できる。 // Double / Double は、Double になる ことはルールで決まっている。 //(Int / Int は、答がおかしくなっても、Int しか返さない、、「1/3 は 0」 になる) fun main() { println(streamlinedFun2(10.0, 3.0)) }