class
All Scala classes are derived from Object(from Java)
Declaration
Usage
Case Classes
convenientaly store and match on class contents(i.e insted of if comp.brand == "HP")
Basically extras on top of class that can be used like a class
Getters, no setters
generates hashcode, toStr, and equals
ez copying
hp20b.copy(brand = "Texas")
Class Modifiers
abstract
cant be instated with new and can have unimplemented its
Sealed & Final
final
can't be extended anywhere and sealed
can only be extended in the same Scala file
Generics
Ez Overloading
Usage
Soooo you can have very natural operator overloading on +
precedence defined as first character so ez i.e a+bc == a+(b\c) regardless of what a, b, and c are
Variance
Basically allows you to answer question if B is subclass of A is Container[B] a subclass of Container[A]
Look up more if you need this
Last updated