Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Specifying Variables
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
flocc




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: