Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 21:37, 14 August 2025 by Dylan (talk | contribs) (new: info, example)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Some programming languages can infer the data type of a variable based on the value that was assigned to the variable.

Importantly, this does not mean the value is untyped (like in dynamic typing), just that we don't need to specify the type because the compiler or interpreter can 'guess' the type.

Example of type inference

edit edit source

Below is an example of type inference in the Rust programming language. The two code snippets below are equivalent:

let x = 17;
let x: i32 = 17;

Many other programming languages have this features, such as C with its 'auto' keyword.