Created
August 20, 2013 13:41
-
-
Save delor/6281593 to your computer and use it in GitHub Desktop.
Watch out when overwriting methods and changing parameter name in Scala.
This file contains hidden or 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> trait Person { def grade(years: Int): String } | |
defined trait Person | |
scala> class SalesPerson extends Person { def grade(yrs: Int) = "Senior" } | |
defined class SalesPerson | |
scala> val s = new SalesPerson | |
s: SalesPerson = SalesPerson@3ce89cd5 | |
scala> s.grade(yrs=1) | |
res0: String = Senior | |
scala> s.grade(years=1) | |
<console>:11: error: not found: value years | |
s.grade(years=1) | |
^ | |
scala> val p: Person = new SalesPerson | |
p: Person = SalesPerson@2709f770 | |
scala> p.grade(years=1) | |
res2: String = Senior |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment