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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -