Cat est un sous-type d'Animal. Mais un Cat[] est-il un Animal[] ? Oui (covariance), pas l'inverse. Et un handler d'Animal passe pour un handler de Cat — la flèche s'inverse (contravariance), et c'est ce qui rend la substitution sûre. Sorties covariantes, entrées contravariantes. Avec deux trous assumés : tableaux mutables covariants, paramètres de méthode bivariants. Cat is a subtype of Animal. But is a Cat[] an Animal[]? Yes (covariance), not the reverse. And an Animal handler stands in for a Cat handler — the arrow flips (contravariance), and that's what makes substitution safe. Outputs covariant, inputs contravariant. With two owned holes: covariant mutable arrays, bivariant method parameters.
Le premier numéro est libre. Débloque tout The TypeScript Loop — tous les volumes, à vie — pour 5 €, paiement unique. The first issue is free. Unlock all of The TypeScript Loop — every volume, forever — for €5, one-time.