So, let's start with a motivational example. Suppose I write the following:
class Foo[+A] {
def foo(a : A) = ???
}
, A +, , Foo A, X <: Y, Foo[X] <: Foo[Y]. , , Foo[X], , Foo[Y]:
def bar(a : Y, x : Foo[Y]) = {
x.foo(a)
}
bar x.foo Y. x Foo[X], x Y - Object , String - , Object , . , Foo - A , - .
, Scala, , - , Scala , , , 't - Foo . , , , , - , (, ) .
, . , :
class Foo[A, B] {
def foo(a : A) = {
def bar(b : B) = ???
}
}
Foo , , , bar . :
class Foo[-A, +B] {
def foo(a : A) = {
def bar(b : B) = ???
}
}