Passing method references to high-order functions
I would like to pass a reference to a method once the object has been instanciated to a high-order function as an argument, but it seems not supported, right?
Example:
4 Replies
The error I receive is something like this:
The alternative
fn() -> Int
definition of the function param, instead of the fn(Foo) -> Int
one does not work either.
Note that comptime, meaning, passing the function as a parameter instead of an argument, is not possible here as we need to instantiate the Foo
objectCan’t you reference it as
Foo.func
and have comptime.Hello @Manuel Saelices, here is an example with parameters:
Wow! Good trick!