In Scala IDE I get the following error about the class I am to compile:
in object MapArea, multiple overloaded alternatives of method addAnim
define default arguments.
So yes, They do! So what? I do not understand the philosophy of this…
UPDATE:
It turns out that there could be a situation where compiler can’t know which method to choose (as pointed out by Tomasz Nurkiewicz), ok I understand.. but in my situation these two methods can clearly be distinguished. Here is the exact piece of code (with all original names and stuff preserved this time):
def addAnim (name: String, x: Float, y: Float, tex: Buffer[Texture], fps: Int, percent: Float = 0): TImageSequence =
addAnim (name, x, y, tex(0).getImage.getWidth, tex(0).getImage.getHeight, tex, fps, percent)
def addAnim (name: String, x: Float, y: Float, w: Float, h: Float, tex: Buffer[Texture], fps: Int, percent: Float = 0): TImageSequence = {
// do stuff
}
It isn’t possible to have two methods with default parameters and with the same name.
Scala generates methods to obtain default values with names based on target method’s name, so some sort of name collision may occur.