| ... | @@ -566,7 +566,7 @@ const c_string_literal = | ... | @@ -566,7 +566,7 @@ const c_string_literal = |
| 566 | {#header_close#} | 566 | {#header_close#} |
| 567 | {#header_close#} | 567 | {#header_close#} |
| 568 | {#header_open|Assignment#} | 568 | {#header_open|Assignment#} |
| 569 | <p>Use <code>const</code> to assign a value to an identifier:</p> | 569 | <p>Use the <code>const</code> keyword to assign a value to an identifier:</p> |
| 570 | {#code_begin|test_err|cannot assign to constant#} | 570 | {#code_begin|test_err|cannot assign to constant#} |
| 571 | const x = 1234; | 571 | const x = 1234; |
| 572 | | 572 | |
| ... | @@ -582,7 +582,8 @@ test "assignment" { | ... | @@ -582,7 +582,8 @@ test "assignment" { |
| 582 | foo(); | 582 | foo(); |
| 583 | } | 583 | } |
| 584 | {#code_end#} | 584 | {#code_end#} |
| 585 | <p>If you need a variable that you can modify, use <code>var</code>:</p> | 585 | <p><code>const</code> applies to all of the bytes that the identifier immediately addresses. {#link|Pointers#} have their own const-ness.</p> |
| | 586 | <p>If you need a variable that you can modify, use the <code>var</code> keyword:</p> |
| 586 | {#code_begin|test#} | 587 | {#code_begin|test#} |
| 587 | const assert = @import("std").debug.assert; | 588 | const assert = @import("std").debug.assert; |
| 588 | | 589 | |
| ... | @@ -1918,7 +1919,7 @@ test "linked list" { | ... | @@ -1918,7 +1919,7 @@ test "linked list" { |
| 1918 | assert(list2.first.?.data == 1234); | 1919 | assert(list2.first.?.data == 1234); |
| 1919 | } | 1920 | } |
| 1920 | {#code_end#} | 1921 | {#code_end#} |
| 1921 | {#header_open|struct naming#} | 1922 | {#header_open|struct Naming#} |
| 1922 | <p>Since all structs are anonymous, Zig infers the type name based on a few rules.</p> | 1923 | <p>Since all structs are anonymous, Zig infers the type name based on a few rules.</p> |
| 1923 | <ul> | 1924 | <ul> |
| 1924 | <li>If the struct is in the initialization expression of a variable, it gets named after | 1925 | <li>If the struct is in the initialization expression of a variable, it gets named after |