A function is a reusable piece of code, given a name, that accepts zero or more inputs and optionally returns a value. Functions are defined by using the fun keyword with optional parameters and a return value. The parameter list must always be present, even if no parameters are defined. For example, this function has no parameters and it returns a hello world value:
fun hello() : String = "hello world"
Each parameter is in the name: type form. The following function accepts two parameters of the String type and also returns a String value. In this case, the returned value is the hello to you string followed by the input parameters:
fun hello(name: String, location: String): String = "hello to you $name at $location"
If a function does not return any meaningful value, then it will return Unit. As discussed in Chapter 2, Kotlin...