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
Post a Comment