Skip to content

Instantly share code, notes, and snippets.

@AndroidPoet
Created May 6, 2022 06:07
Show Gist options
  • Save AndroidPoet/4e647136f7b2ddaf5b8d7da02404d992 to your computer and use it in GitHub Desktop.
Save AndroidPoet/4e647136f7b2ddaf5b8d7da02404d992 to your computer and use it in GitHub Desktop.
Kotlin Functions
fun main() {
printMessage("Hello")
printMessageWithPrefix("Hello", "World")
sum(4, 5)
multiply(4, 5)
}
fun printMessage(message: String) {
println(message)
}
fun printMessageWithPrefix(message: String, prefix: String = "This is String") {
println("$message $prefix")
}
fun sum(x: Int, y: Int) {
println("Sum")
println(x + y)
}
fun multiply(x: Int, y: Int) = println("Multiply" + x * y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment