Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. val i = 12345
  2. val f = 1234.5F
  3. val d = 1234.5D
  4. val arr = Array[Any](i,f,d)
  5. val anotherD = arr(0).asInstanceOf[Numeric].toDouble
  6.  
  7. scala> val i = 12345
  8. i: Int = 12345
  9.  
  10. scala> val f = 1234.5F
  11. f: Float = 1234.5
  12.  
  13. scala> val d = 1234.5D
  14. d: Double = 1234.5
  15.  
  16. scala> val arr = Array[Any](i,f,d)
  17. arr: Array[Any] = Array(12345, 1234.5, 1234.5)
  18.  
  19. scala> val anotherD = arr(0).asInstanceOf[Numeric].toDouble
  20. <console>:11: error: type Numeric takes type parameters
  21. val anotherD = arr(0).asInstanceOf[Numeric].toDouble
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement