Named Parameters

fun findMyAge(currentYear: Int, birthYear: Int) {
   var myAge = currentYear -birthYear
println("I am $myAge years old.")
}
fun main() {
  findMyAge(currentYear = 2020, birthYear = 1995)
  //Prints: I am 25 years old.
  findMyAge(birthYear = 1920, currentYear = 2020)
  //Prints: I am 100 years old.
}
Comments