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

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -