Is it possible to write something similar to:
def foo(x: Int, y: Double)
def bar(x: Int, y: Double) = foo(_)
I would like to avoid repeating myself in saying:
def foo(x: Int, y: Double)
def bar(x: Int, y: Double) = foo(x, y)
So in the case where the both parameter lists are the same in type and size and no repositioning of parameters should happen, can something like parameter forwarding achieved?
Yes, if the function bar is doing nothing other than forwarding exactly on to
foo, you can do the following:In this case the underscore indicates that you want to return the function
fooitself, rather than calling it and returning the reuslt. This means that whenbaris called, it will simply return the functionfoo, which will then be called with the arguments you provided.