zam zam - 1 year ago 109
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

Answer Source

Missing dot .


if(t._1.isInstanceOf[String]) println("yes") 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download