Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [OK]
- def sum(a:Int,b:Int) = a+b
- [NG]
- def sum(a:Int,b:Int) = a+b
- def sum(a:Int,b:String) = sum(a, b.toInt)
- // (compile error)
- // overloaded method sum needs result type
- // def sum(a:Int,b:String) = sum(a, b.toInt)
- [OK]
- def sum(a:Int,b:Int) = a+b
- def sum(a:Int,b:String):Int = sum(a, b.toInt)
Add Comment
Please, Sign In to add comment