Dynamic typing
Dynamic typing (English dynamic typing ) denotes the fact that Type tests are carried out primarily for the duration of a program.
Examples
Python
Here is an interactive Python session:
A = 1 >>> # a contains by assigning an integer
>>> A = 1.0 # adds the floating point number 1.0 and sets new value (with a different type) in a from
A.upper >>> () # fails: a is not a string
Traceback ( most recent call last):
File "
Boo
Example from the project site
D as duck d = 5 / / currently set to to integer. print d d = 10 / / It can do everything does to integer. print d d = " Hi there " / / sets it to a string print d d = d.ToUpper () / / It can do everything a string does. print d issue:
5 15 Hi there! HI THERE Explanation of Example
There the variable d is created and it is the data type assigned to duck. This is not a real data type, but only a kind of container that can accept other types of data. In the second row is assigned the integer value 5 d.
In line 6, it is assigned the string Hi there. In other programming languages such as C # or C , this would now lead to a compiler error.
The Boo compiler, however, recognizes the data type of duck that the data type of the variable d may change.