Skip to content

Instantly share code, notes, and snippets.

@delor
Created August 20, 2013 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save delor/6281593 to your computer and use it in GitHub Desktop.
Save delor/6281593 to your computer and use it in GitHub Desktop.
Watch out when overwriting methods and changing parameter name in Scala.
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