`T extends U ? X : Y` lets types branch on shape. Combine with `infer` to extract pieces of complex types — the building block under `ReturnType`, `Parameters`, and most utility libraries.
Three classic functional combinators, generically typed. Go's standard library doesn't ship these (yet), but they're short enough to drop into any project.
Generics start unbounded — you can't access any properties of `T`. `T extends { … }` adds a constraint so the body can safely use known shape, while callers can still pass in narrower types.
`out T` (covariant) → producer of T; can be assigned to a wider type. `in T` (contravariant) → consumer of T; can be assigned to a narrower type. Without modifiers, generics are invariant (strict match).
Producer-Extends, Consumer-Super. `? extends T` is read-only (you can take items OUT). `? super T` is write-only (you can put items IN). Lets generic APIs accept a wider range of types.
Encode "this might fail" in the type signature instead of throwing. Python 3.12+ generics syntax keeps it compact. Forces the caller to handle the failure branch.
TypeScript is structurally typed, so `string` and `string` are interchangeable even when they semantically aren't (UserId vs PostId). The "brand" trick adds a phantom property that exists only at compile time, giving you nominal-ish typing.
`List<*>` means "list of something I don't need to know exactly" — read-only with Any? as element type. Useful when you genuinely don't care about the parameter.
In an `inline` function, a `reified` type parameter survives erasure — you can use `T::class`, `is T`, `as T` at runtime. The killer use-case for JSON parsers ("give me a List<User>").
`<T>` declares a type parameter. Use it on classes (`Box<T>`) and functions (`fun <T> identity(x: T) = x`). Type bounds (`T : Comparable<T>`) constrain what T can be.