Last active
August 29, 2015 14:01
-
-
Save fedesilva/3593e3944897c3011d8f to your computer and use it in GitHub Desktop.
Overloading and Named Parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OverloadAndNamedParameters { | |
def method(arg1: Int, arg2: Int, arg3: String) = println( "Method1") | |
def method(arg1: Int, arg3: String) = println( "Method2" ) | |
def method(arg1: Int, arg2: Double, arg3: String) = println( "Method3" ) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> d.method(arg3="fede") | |
<console>:9: error: overloaded method value with alternatives: | |
(arg1: Int,arg2: Double,arg3: String)Unit <and> | |
(arg1: Int,arg3: String)Unit <and> | |
(arg1: Int,arg2: Int,arg3: String)Unit | |
cannot be applied to (arg3: String) | |
d.method(arg3="fede") | |
^ | |
scala> d.method(1, arg3="fede") | |
Method1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment