Skip to content

Instantly share code, notes, and snippets.

@maiha
Created May 17, 2010 03:56
Show Gist options
  • Save maiha/403383 to your computer and use it in GitHub Desktop.
Save maiha/403383 to your computer and use it in GitHub Desktop.
[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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment