| ... | @@ -575,32 +575,27 @@ pub fn main() void { | ... | @@ -575,32 +575,27 @@ pub fn main() void { |
| 575 | var optional_value: ?[]const u8 = null; | 575 | var optional_value: ?[]const u8 = null; |
| 576 | assert(optional_value == null); | 576 | assert(optional_value == null); |
| 577 | | 577 | |
| 578 | print("\noptional 1\ntype: {s}\nvalue: {?s}\n", .{ | 578 | print("\noptional 1\ntype: {}\nvalue: {?s}\n", .{ |
| 579 | @typeName(@TypeOf(optional_value)), | 579 | @TypeOf(optional_value), optional_value, |
| 580 | optional_value, | | |
| 581 | }); | 580 | }); |
| 582 | | 581 | |
| 583 | optional_value = "hi"; | 582 | optional_value = "hi"; |
| 584 | assert(optional_value != null); | 583 | assert(optional_value != null); |
| 585 | | 584 | |
| 586 | print("\noptional 2\ntype: {s}\nvalue: {?s}\n", .{ | 585 | print("\noptional 2\ntype: {}\nvalue: {?s}\n", .{ |
| 587 | @typeName(@TypeOf(optional_value)), | 586 | @TypeOf(optional_value), optional_value, |
| 588 | optional_value, | | |
| 589 | }); | 587 | }); |
| 590 | | 588 | |
| 591 | // error union | 589 | // error union |
| 592 | var number_or_error: anyerror!i32 = error.ArgNotFound; | 590 | var number_or_error: anyerror!i32 = error.ArgNotFound; |
| 593 | | 591 | |
| 594 | print("\nerror union 1\ntype: {s}\nvalue: {!}\n", .{ | 592 | print("\nerror union 1\ntype: {}\nvalue: {!}\n", .{ |
| 595 | @typeName(@TypeOf(number_or_error)), | 593 | @TypeOf(number_or_error), number_or_error, }); |
| 596 | number_or_error, | | |
| 597 | }); | | |
| 598 | | 594 | |
| 599 | number_or_error = 1234; | 595 | number_or_error = 1234; |
| 600 | | 596 | |
| 601 | print("\nerror union 2\ntype: {s}\nvalue: {!}\n", .{ | 597 | print("\nerror union 2\ntype: {}\nvalue: {!}\n", .{ |
| 602 | @typeName(@TypeOf(number_or_error)), | 598 | @TypeOf(number_or_error), number_or_error, |
| 603 | number_or_error, | | |
| 604 | }); | 599 | }); |
| 605 | } | 600 | } |
| 606 | {#code_end#} | 601 | {#code_end#} |
| ... | @@ -859,7 +854,7 @@ const mem = @import("std").mem; // will be used to compare bytes | ... | @@ -859,7 +854,7 @@ const mem = @import("std").mem; // will be used to compare bytes |
| 859 | | 854 | |
| 860 | pub fn main() void { | 855 | pub fn main() void { |
| 861 | const bytes = "hello"; | 856 | const bytes = "hello"; |
| 862 | print("{s}\n", .{@typeName(@TypeOf(bytes))}); // *const [5:0]u8 | 857 | print("{}\n", .{@TypeOf(bytes)}); // *const [5:0]u8 |
| 863 | print("{d}\n", .{bytes.len}); // 5 | 858 | print("{d}\n", .{bytes.len}); // 5 |
| 864 | print("{c}\n", .{bytes[1]}); // 'e' | 859 | print("{c}\n", .{bytes[1]}); // 'e' |
| 865 | print("{d}\n", .{bytes[5]}); // 0 | 860 | print("{d}\n", .{bytes[5]}); // 0 |