fun class_name.function_name(parameters): type
{
...
}
Kotlin
fun List<Float>.myAverage(): Float
{
return this.sum() / this.count()
}
fun main() {
val values:List<Float> = listOf(7.0f, 9.0f)
val value = values.myAverage() // call a new function
println(value)
// on the screen we will see 8
}