scala - How to define class method with partially applied function? -


i want define class's method partially applied method. possible without applying method?

this best shot:

def getfile1(arg1: string) (implicit execution: executioncontextexecutor): future[file] =   getfile("file 1")_  def getfile2(arg1: string) (implicit execution: executioncontextexecutor): future[file] =   getfile("file 2")_  def getfile(filename: string)(arg1: string)(implicit execution: executioncontextexecutor): future[file] = //... 

what happens though instead of making getfile1(arg1) , getfile('file 1', arg1) equivalent, scala tries evaluate getfile("file 2")_ , sees error because type of getfile("file 2")_ function, not file.

the error correct. getfile("..")_ expression inside method (that evaluates partial function) , not 'a method definition'.

writing out following should make more clear:

def getfile2(arg1: string) (implicit execution: executioncontextexecutor): future[file] = {   return getfile("file 2")_ } 

contrast getfile("file 2")(arg1), has expected expression type/result of future[file].

if wanting method return partially applied function change return type future[file] whatever appropriate. (or let type inference it's gonna do.)


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -