Let's say I have a method expecting another method as a parameter. Is it possible to send an object's instance methods for that parameter? How would I handle methods that have no parameters?
I'll write some pseudocode:
void myMethod1(callback<void,int> otherFunc); // imagine a function returning void, and taking a int parameter
void myMethod2(callback<int,void> otherFunc); // function returning void, not taking params
if for example I have an ArrayList, like this:
val a = new ArrayList()
how could I send it's add
method as parameter for myMethod1
, and it's size
method as parameter for myMethod2
?