class New {
val x : Option[String] = "abc"
val y : String = "abc"
if(x == y) "YES" else "No"
}
**Error:(5, 28) type mismatch;
found : String("abc")
required: Option[String]
val x : Option[String] = "abc"**
I am facing above type mismatch error. Can someone help to resolve above error?
Stringvalue toxbut declarexasOption[String]this is different types. try to wrap"abc":Option("abc")and after that you will need to wrapyalso for comparing. Read more about option for using it correctly.