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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -