When creating new functions, we often need to allow some of their parameters to be optional. This forces us to use method overloading to create multiple function declarations with the same name but different sets of arguments related to different use cases and scenarios. Usually, under the hood, each variant of the function is calling the base function with the default implementation. Let's consider a simple example of a function that calculates a displacement of an object moving with a constant acceleration rate:
fun calculateDisplacement(initialSpeed: Float,
acceleration: Float,
duration: Long): Double =
initialSpeed * duration + 0.5 * acceleration * duration * duration
We might also need to provide a displacement calculation for the scenario where the initial speed...