Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- println("Returned: "+determineKind(3).getClass)
- def determineKind( input:Int ):Any = {
- val aResult = input match {
- case a if(a<5) =>
- val r = a.toInt
- println("HERE! "+r.getClass) // shows expected 'int' type
- r
- case a if(a<50) => a.toLong
- case a if(a<100) => a.toFloat
- case a => a.toDouble
- }
- println(aResult.getClass) // This is now Double!
- aResult
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement