I was trying to convert an object with Object type into FontUIResource type. In Java, it would be
FontUIResource font = (FontUIResource)value
How would I do that in Scala?
I was trying to convert an object with Object type into FontUIResource type. In Java, it would be
FontUIResource font = (FontUIResource)value
How would I do that in Scala?
You mean casting, not Boxing and Unboxing, since that applies to primitive values. value.asInstanceOf[FountUIResource]
is the way to cast this in Scala.
You can say value.asInstanceOf[FontUIResource]
, or you can use a match-case block:
value match{
case f:FontUIResource =>
//do something with f, which is safely cast as a FontUIResource
case _ =>
//handle the case when it's not the desired type
}