This commit is contained in:
Adam Millerchip 2022-01-01 02:42:09 +09:00
parent de9e407e15
commit bd7e87fb25
1 changed files with 7 additions and 7 deletions

View File

@ -40,7 +40,7 @@
// (Notice how the two functions which return types start with
// uppercase letters? This is a standard naming practice in Zig.)
//
const print = import(std).debug.print; // Oops!
const print = @import("std").debug.print; // Oops!
const Narcissus = struct {
me: *Narcissus = undefined,
@ -57,8 +57,8 @@ pub fn main() void {
// Oops! We cannot leave the 'me' and 'myself' fields
// undefined. Please set them here:
??? = &narcissus;
??? = &narcissus;
narcissus.me = &narcissus;
narcissus.myself = &narcissus;
// This determines a "peer type" from three separate
// references (they just happen to all be the same object).
@ -68,7 +68,7 @@ pub fn main() void {
// this function. It is namespaced to the struct, but doesn't
// use the method syntax (there's no self parameter). Please
// fix this call:
const T2 = narcissus.fetchTheMostBeautifulType();
const T2 = Narcissus.fetchTheMostBeautifulType();
print("A {} loves all {}es. ", .{ T1, T2 });
@ -103,15 +103,15 @@ pub fn main() void {
// Please complete these 'if' statements so that the field
// name will not be printed if the field is of type 'void'
// (which is a zero-bit type that takes up no space at all!):
if (fields[0].??? != void) {
if (fields[0].field_type != void) {
print(" {s}", .{@typeInfo(Narcissus).Struct.fields[0].name});
}
if (fields[1].??? != void) {
if (fields[1].field_type != void) {
print(" {s}", .{@typeInfo(Narcissus).Struct.fields[1].name});
}
if (fields[2].??? != void) {
if (fields[2].field_type != void) {
print(" {s}", .{@typeInfo(Narcissus).Struct.fields[2].name});
}