If I have a function with parameter param: () -&gt...
# announcements
j
If I have a function with parameter param: () -> Boolean how can I call this function using method reference Foo:myFunction as a parameter?
d
What's
Foo
here? A class?
j
Good question, interface actually
d
Then your
param
either needs an instance parameter or you need to do
someFooInstance::myFunction
j
The actual use case is that I need to call this function in two places, other just () -> true and other using Foo:myFunction
d
Well
Foo::myFunction
is of type
Foo.() -> Boolean
, it needs the actual instance of
Foo
to call the method on.
If you want
() -> Boolean
you need to pre-bind the receiver:
myInstance::myFunction
j
ah, correct, forgot about that.