Guest User

Untitled

a guest
May 25th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. [OK]
  2. def sum(a:Int,b:Int) = a+b
  3.  
  4. [NG]
  5. def sum(a:Int,b:Int) = a+b
  6. def sum(a:Int,b:String) = sum(a, b.toInt)
  7.  
  8. // (compile error)
  9. // overloaded method sum needs result type
  10. // def sum(a:Int,b:String) = sum(a, b.toInt)
  11.  
  12. [OK]
  13. def sum(a:Int,b:Int) = a+b
  14. def sum(a:Int,b:String):Int = sum(a, b.toInt)
Add Comment
Please, Sign In to add comment