|
May 2, 2002 The Risk of Un-typed Variables Tips: May 2002
Yehuda Shiran, Ph.D.
|
|
JScript .NET's support for un-typed
variables makes it very easy to develop short scripts. Novice and occasional developers
can focus more on the business logic, rather than being concerned with what types
their variables are. The drawback to using un-typed variables is that the results
are not always what you would expect. Let's take the following example:
What do you think the value of z will be? Since we did not declare the types of x and y, the compiler casts one of them to the other. In the case above, z will be 22. The variable y is casted to String and concatenated with x.To learn more on JScript .NET, go to Column 108, JScript .NET, Part II: Major Features.
People who read this tip also read these tips: Look for similar tips by subject: |
| ||||||||||||||||||||