Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changes between Version 1 and Version 2 of DeclaringVariables/D2

Show
Ignore:
Author:
Andrej08 (IP: 78.2.39.16)
Timestamp:
09/06/10 21:19:44 (11 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeclaringVariables/D2

    v1 v2  
    33''Part of'' TutorialFundamentals 
    44 
    5 In order to store information within a D program, you must declare variables before they are used. The syntax is ''type_name'' ''identifier''. You can also use the '''auto''' keyword in place of a type qualifier, which means the type of the variable is implicitly inferred from the right hand side. 
     5In order to store information within a D program, you must declare variables before they are used. The syntax is ''type_name'' ''identifier''. You can also use the '''auto''' keyword in place of a type, which means the type of the variable is implicitly inferred from the right hand side. 
    66 
    77{{{ 
    1919}}} 
    2020 
     21Additionally, a variable can be marked as const or immutable, with the default being changeable (mutable). 
     22 
     23{{{ 
     24#!d 
     25void main() 
     26{ 
     27    const int myInteger = 4; 
     28    myInteger = 5; // Error, myInteger is constant 
     29} 
     30}}} 
     31 
    2132== D1.x vs D2.x == 
    2233