]>
A declaration is an expression used to restrict the type of values that can be assigned to variables. A colon ``:'' is always used after a variable or list of variables to be declared.
For a single variable, the syntax for declaration is
variableName typeOrMode
For multiple variables, the syntax is
(, , ... ): typeOrMode
You can always combine a declaration with an assignment. When you do, it is equivalent to first giving a declaration statement, then giving an assignment. For more information on assignment, see Section ugIntroAssign and Section ugLangAssign . To see how to declare your own functions, see ugUserDeclare .
This declares one variable to have a type.
This declares several variables to have a type.
, and can only hold integer values.
If a value cannot be converted to a declared type, an error message is displayed.
This declares a variable with a mode.
This declares several variables with a mode.
This complex object has integer real and imaginary parts.
This complex object has fractional symbolic real and imaginary parts.
This matrix has entries that are polynomials with integer coefficients.
This matrix has a single entry that is a polynomial with rational number coefficients.
This matrix has entries that are polynomials with complex integer coefficients.
Note the difference between this and the next example. This is a complex object with polynomial real and imaginary parts.
This is a polynomial with complex integer coefficients. The objects are convertible from one to the other. See ugTypesConvert for more information.