function kotlin
// Declare a function in Kotlin
fun happyBirthday(name: String, age: Int): String {
return "Happy ${age}th birthday, $name!"
}
// Call function
val greeting = happyBirthday("Anne", 32)
function kotlin
// Declare a function in Kotlin
fun happyBirthday(name: String, age: Int): String {
return "Happy ${age}th birthday, $name!"
}
// Call function
val greeting = happyBirthday("Anne", 32)
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
}
make function kotlin
fun main() {
println("This is a function")
}
how to do a function kotlin
//Okay I found a couple of examples, but I think this one should help the beginners out there who need the syntax!
fun callMe() {
println("Hello")
println("cool")
}
fun main() {
callMe()
println("Printing outside from callMe() function.")
}
//I hope it helps out! I try to make new languages hopefully easy for you to learn!
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