Type Safety
The Cadence programming language is a type-safe language.
When assigning a new value to a variable, the value must be the same type as the variable. For example, if a variable has type Bool
, it can only be assigned a value that has type Bool
, and not for example a value that has type Int
.
When passing arguments to a function, the types of the values must match the function parameters' types. For example, if a function expects an argument that has type Bool
, only a value that has type Bool
can be provided, and not for example a value which has type Int
.
Types are not automatically converted. For example, an integer is not automatically converted to a boolean, nor is an Int32
automatically converted to an Int8
, nor is an optional integer Int?
automatically converted to a non-optional integer Int
, or vice-versa.
Last updated