Scala trait override method with multiple parameters

Viewed 203

I would love to create trait called filter with method execute and force all children to have execute but in some filters execute may need some other parameters and some don't. Is here any way how to create child with different parameters and parent ?

Maybe pattern matching could be solution in some way. Also Im new user of Scala so I ll be happy for all advices

Example code:

trait filter{
    def execute (photo: Photo): Photo 
}

object FooFilter{
    // Here we will get compile error due that execute method is not overloading anything
    override def execute (photo: Photo, foo: Foo): Photo = {...} 
}
0 Answers
Related