mardi 24 février 2015

Scala : constructor cannot be instantiated to expected type found

I tried to pattern match against the simple class below



case class Name(first : String, second : String)


with



val n = Name("John","Doe")
n match{case Name(x,y) => x + y}


But I got this error



error: constructor cannot be instantiated to expected type;
found: Name
required: Name


I don't understand why it is so since both found and required are of the same type.


Any help?


Aucun commentaire:

Enregistrer un commentaire