Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- subclass stuff
- there can be a thing that is a subclass of two parent classes-- a Mermaid is a Fish and a Person
- how about a Furniture and a Vehicle? wheelchair
- class Foo extends Bar implements I1,I2,I3... (this is Java)
- Scala--
- class Foo extends Bar with T1, T2, T3...
- trait T1... etc etc
- Which do you pick if both parents have the same method with different implementations?
- "overloading"
- def foo(x:Int)
- def foo(x:Int, b:Boolean)
- and that is how you tell them apart
- how do you decide?
- - alphabetical? depth of parent? fastest? pick from first parent listed?
- - or, programmer must specify
- ========
- class Foo
- val x
- def f(): Mammal
- def g(x: Mammal): Unit
- class Bar extends Foo
- def f(): Cat // this is covariance -- methods only
- def g(x: Animal): Unit // this is contravariance -- parameters only
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement