I'm working on a project in scala, and was wondering if there is some way I could define some set of methods that would all have the same code, for instance, all functions that start with the letter c. For instance:
class A {
a() {..}
b() {..}
c[a-z]+() {...}
}
var a = new A();
a.click();
a.cook()
In this example, click() and cook() would both call the c[A-Z]+ method
Would it be possible to create such functionality or is it outside Scala's capabilities?
Alternatively, is there some way to allow all possible method calls on an object, and have a sort of "default" method
class B {
a() {..}
b() {..}
default() {...}
}
var b = new B();
b.somethingelse();
where somethingelse() would actually call default() but still have access to the somethingelse() method name.