Specifying Variables
Author |
Message |
flocc
|
Posted: Thu Jul 28, 2011 12:35 pm Post subject: Specifying Variables |
|
|
What is the problem you are having?
I'm just beginning turing and I just have a quick question: when do you have to specify a variable?
Sometimes you're able to just put (var x:=3) or (var x:="t") without specifying whether it's an int or string. So when can or should you specify?
Please specify what version of Turing you are using
I am using Turing 4.1.1 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
DemonWasp
|
Posted: Thu Jul 28, 2011 12:44 pm Post subject: RE:Specifying Variables |
|
|
You can always specify the type. In general, you should always specify the type.
However, if Turing can determine at compile-time what type you are assigning to that variable, then it can use that type by default. So, if you assign 3, it knows that 3 is an integer, so the type is int. If you assign "three", then the type will be string. If it's 3.1, that's a real number, so the type is real.
However, giving the actual type you expect will never hurt anything and it may help you avoid some bugs. |
|
|
|
|
![](images/spacer.gif) |
|
|