How to define a trait with an abstract method that need to be present even tho it can have different arguments. I just want to make sure the class that extends the trait has the method and the same return type. The example bellow (mainly illustrative) overloads the "add" and gives an error that "add" needs to be defined. How should I change the method declaration in the Trait?
Unfortunately all the answers don't work. I am not sure if I was clear, but I don't want to have any defined types in the arguments to be defined/checked (Any, generic, type definition) as the type of it and number of arguments can change, in my case the return could be the same. I just want it to check if a method with the same name and return is present ignoring the arguments. "Any" is not an alternative as it is not typesafe and I want to define clearly what the functions expect as arguments.
Example:
trait X{
def add: Boolean
}
class Y extends X {
def add(i: Int, s: String) : Boolean = {...}
}
class W extends X {
def add(i: Int, y: Int, w: Set[String]) : Boolean = {...}
}
X
be able to call these methods? – Lee