I was looking at the documentation for PartialFunction in this link:
trait PartialFunction[-A, +B] extends (A) ⇒ B
Maybe someone can help clari
It's covariance and contravariance. https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)
Basically it says for Generic types how inheritance will work.
Easy sample from Scala is - trait Seq[+A]
Because of the + , the code
val s: Seq[Person] = Seq[Student]()
will compile because Student extends Person. Without the + it won't work
A bit more complex sample -
class C[-A, +B] {
def foo(param: A): B = ???
}
class Person(val name: String)
class Student(name: String, val university: String) extends Person(name)
val sample: C[Student, Person] = new C[Person, Student]