#help make this correct

1 messages · Page 1 of 1 (latest)

proud quiver
#
const std = @import("std");

pub fn main() !void {
    const users_array = [_][]const u8{ "david", "john" };

    for (users_array, 0..) |user, index| {
        std.debug.print("name: {s}\n no: {d}\n", .{ user, if (index == 0) {
            return index + 1;
        } else {
            return index;
        } });
    }
}

modest sky
#
const std = @import("std");

pub fn main() !void {
    const users_array = [_][]const u8{ "david", "john" };

    for (users_array, 0..) |user, index| {
        std.debug.print("name: {s}\n no: {d}\n", .{ user, if (index == 0)
            index + 1
        else
            index
        });
    }
}