scala - type inference and string literals, how to do it? -
how compile?
code
object playground2 { trait client[s,a] { def wrap[s,a](v: a): (s,a) } class testclient extends client[string, int] { override def wrap[string,int](v: int): (string, int) = ("cache 2.00", v) } }
error type mismatch; found : java.lang.string("cache 2.00") required: string
here's version of code compiles:
object playground2 { trait client[s,a] { def wrap(v: a): (s,a) } class testclient extends client[string, int] { override def wrap(v: int) = ("cache 2.00", v) } }
you duplicated types again in wrap
function , did not need defined on trait itself.
Comments
Post a Comment