You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Anonymous structs can be created without specifying field names, and are referred to as "tuples".
3583
3549
</p>
3584
3550
<p>
3585
3551
The fields are implicitly named using numbers starting from 0. Because their names are integers,
3586
-
the {#syntax#}@"0"{#endsyntax#} syntax must be used to access them. Names inside {#syntax#}@""{#endsyntax#} are always recognised as {#link|identifiers|Identifiers#}.
3552
+
they cannot be accessed with {#syntax#}.{#endsyntax#} syntax without also wrapping them in
3553
+
{#syntax#}@""{#endsyntax#}. Names inside {#syntax#}@""{#endsyntax#} are always recognised as
3554
+
{#link|identifiers|Identifiers#}.
3587
3555
</p>
3588
3556
<p>
3589
-
Like arrays, tuples have a .len field, can be indexed and work with the ++ and ** operators. They can also be iterated over with {#link|inline for#}.
3557
+
Like arrays, tuples have a .len field, can be indexed (provided the index is comptime-known)
3558
+
and work with the ++ and ** operators. They can also be iterated over with {#link|inline for#}.
3590
3559
</p>
3591
3560
{#code_begin|test|tuple#}
3592
3561
const std = @import("std");
@@ -6488,7 +6457,22 @@ test "coercion between unions and enums" {
6488
6457
{#see_also|union|enum#}
6489
6458
{#header_close#}
6490
6459
{#header_open|Type Coercion: undefined#}
6491
-
<p>{#link|undefined#} can be cast to any type.</p>
6460
+
<p>{#link|undefined#} can be coerced to any type.</p>
6461
+
{#header_close#}
6462
+
6463
+
{#header_open|Type Coercion: tuples to arrays#}
6464
+
<p>{#link|Tuples#} can be coerced to arrays, if all of the fields have the same type.</p>
0 commit comments