zam zam - 6 months ago 53
Scala Question

Comparing objects using isinstanceOf

I'm trying to use the isInstanceOf operator to get a value from a tuple and checking whether its of a specific type. I'm scratching my head over the error and I don't want to use match cases.

val t = ("ww",2, 3.4)

if(t._1 isInstanceOf[String])

The error I get is:

<console>:1: error: type application is not allowed for postfix operators


Missing dot .


if(t._1.isInstanceOf[String]) println("yes")