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

patch 48 appears to be wrong #48

Closed
happysalada opened this issue Apr 25, 2021 · 3 comments
Closed

patch 48 appears to be wrong #48

happysalada opened this issue Apr 25, 2021 · 3 comments

Comments

@happysalada
Copy link

patch 48 shows

57c57
<             e = e.???; // Which method do we want here?
---
>             e = e.getTail(); // Which method do we want here?

trying to run this with zig build will give an error

modifying the while on line 52 seems to be the correct answer.
So that the while look is

    while (!e.visited) {
        e.print();
        e.visit();

        // Get the next elephant or stop.
        if (e.hasTail()) {
            e = e.getTail(); // Which method do we want here?
        } else {
            break;
        }
    }

I'm only mentioning this because path 49 appears to be wrong too. You need to modify the while loops and add another statement to make it work.

I'm writing an issue since perhaps, I'm wrong of course.

@ratfactor
Copy link
Owner

@happysalada I use those patches to test after every change I make, so I know they still work. That should, in fact, be the correct answer to 048.

But maybe I'm not understanding what you're saying. The while loop in the exercise looks like this:

    while (true) {
        e.print();
        e.visit();

        // Get the next elephant or stop.
        if (e.hasTail()) {
            e = e.???; // Which method do we want here?
        } else {
            break;
        }
    }

And when I make the fix (as shown in the patch), the getTail() method is filled in correctly and it works.

We don't need !e.visited in the while condition because the break statement is checking the optional value returned from hasTail(), which is what we want.

What error are you getting?

Thanks!

@happysalada
Copy link
Author

Oh, got it, I had added

    elephantC.tail = &elephantA;

I thought that line was an order and you were supposed to do something about it.
My bad

@ratfactor
Copy link
Owner

@happysalada Oh, I see! You're right, some of the comments are hard to distinguish from exercise instructions.

I've updated 048 and 049 to change things like "Get the next..." to "This gets the next...".

Thank you for pointing this out!

vamega pushed a commit to vamega/ziglings that referenced this issue Jul 25, 2023
monadplus pushed a commit to monadplus/ziglings that referenced this issue Feb 18, 2024
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

2 participants