types - Found scala.Unit, required Unit -


i have simple container trait so:

trait handler {   def apply[in, out](in: in): out } 

when try implement it:

new handler {   def apply[any, unit](in: any) = println(in) } 

i error:

[error]  found   : scala.unit [error]  required: unit(in method apply) [error]       def apply[any, unit](in: any) = println(in) 

why this? can fix compiler error?

there same question correct answer.

you use trait type parameter, not method type parameter:

trait handler[out] {   def apply[in](in: in): out }  new handler[unit] {   def apply[in](in: in) = println(in) } 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -