how to write a function in kotlin
// Use 'fun' keyword to declare function
// 'num' is the parameter and is of type Int
// The ':Int' indicates the return type
fun square(num: Int):Int {
return num * num
}
how to write a function in kotlin
// Use 'fun' keyword to declare function
// 'num' is the parameter and is of type Int
// The ':Int' indicates the return type
fun square(num: Int):Int {
return num * num
}
kotlin variable in string
//Kotlin variable in string
//variables go in a ${} in a string, example
println("Happy ${age}th birdthday, ${name}!"
kotlin method return
fun sum(val a: Int, val b: Int): Int {
return a+b
}
fun sum(val a: Int, val b: Int) = a + b
kotlin function return
fun sum(a: Int, b: Int): Int {
return a + b
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us