I tried to convert an object with an object type to a FontUIResource type. In Java, it will be
FontUIResource font = (FontUIResource)value
How do I do this in Scala?
You can say value.asInstanceOf[FontUIResource], or you can use the matching block:
value.asInstanceOf[FontUIResource]
value match{ case f:FontUIResource => //do something with f, which is safely cast as a FontUIResource case _ => //handle the case when it not the desired type }
You mean casting, not boxing and Unboxing, as this applies to primitive values. value.asInstanceOf[FountUIResource]is a way to do it in Scala.
value.asInstanceOf[FountUIResource]
Source: https://habr.com/ru/post/1764099/More articles:Using polyorphic_path, getting the error "undefined method" merge "" - ruby-on-railsGoogle Chrome Plugin: Determining the URL of the selected tab - javascriptVideoView in ViewFlipper is transparent when playing video - androidVideoView plays normally, but not displayed when switching full-screen views - androidQR code source that runs on Blackberry - javaDistributed low latency cache for Java & C ++ Object - javaHow to preload all default tabs using jQuery - jqueryProblem with istream :: tellg ()? - c ++wpf validation - how can I get this code to initiate validation when typing (cf when exiting a field) - c #How to show a white popup on a custom Google map? - javascriptAll Articles