Basic Syntax

Type Inference

English

Overview

A mechanism where the compiler determines a type automatically, without it being written explicitly.

Details

A mechanism where the compiler automatically determines a variable's type from the assigned value or context, reducing how much you have to write while still getting the benefits of static typing. In most languages, the type can't be inferred unless the variable is initialized at the point of declaration, so a type-inferred variable -- like TypeScript's let or C#'s var -- effectively requires initialization right there.

More Programming terms