hey just new to kotlin from java and i want to ask if is possible to have two functions with the same name , for example i have a function name is " PrintVal " i want at least to make a three of this without to change the name how can doing this in kotlin
CodePudding user response:
we can this way called overloading
Overloading refers to the ability to use a single identifier to define multiple methods of a class that differ in their input and output parameter make your functions but just change the parameter ( you should have a parameters)
Example :
fun printVal(a : Int , b : Int){
println(a b)
}
fun printVal(a : Float , b: Float){
println(a b)
}