Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More descriptive code samples #284

Open
ellnix opened this issue Dec 8, 2024 · 0 comments
Open

More descriptive code samples #284

ellnix opened this issue Dec 8, 2024 · 0 comments

Comments

@ellnix
Copy link

ellnix commented Dec 8, 2024

Going through this guide and enjoying it so far. I'm writing this issue to ask whether it would benefit the website if the code samples used more descriptive names for things like constants, variables, and tests. In quite a few cases it feels like they were written temporarily and not refactored.

I would be happy to make PRs toward this, just thought I'd make an issue first to make sure that this is something worth doing.

Examples:

Current:

test "hmm" {
    Mode.count += 1;
    try expect(Mode.count == 1);
}

Suggestion:

test "enum namespaced variable" {
    Mode.count += 1;
    try expect(Mode.count == 1);
}

Current:

test "automatic dereference" {
    var thing = Stuff{ .x = 10, .y = 20 };
    thing.swap();
    try expect(thing.x == 20);
    try expect(thing.y == 10);
}

Suggestion:

test "automatic dereference" {
    var p = Point{ .x = 10, .y = 20 };
    p.swap();
    try expect(p.x == 20);
    try expect(p.y == 10);
}

The official zigs documentation on structs also seems to use Point as an example, not that it really matters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant