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

The "must diverge" statement for let ... else expressions may be confusing #2473

Open
gendx opened this issue Nov 25, 2024 · 1 comment
Open

Comments

@gendx
Copy link
Collaborator

gendx commented Nov 25, 2024

The slide about let ... else expressions mentions that:

For the common case of matching a pattern and returning from the function, use let else. The "else" case must diverge (return, break, or panic - anything but falling off the end of the block).

However, the code just after is about if let ... else, for which the else block doesn't need to diverge.

The code example for let ... else is hidden in the speaker notes, but that slide is quite long so a speaker may miss it.

@djmitche
Copy link
Collaborator

djmitche commented Nov 26, 2024

The idea here is

Rewrite the awkward version for students, so they can see the transformation

but that's easy to miss, especially if doing the course without an instructor. How could we show the "triangle" of nested if-let's that the let-else syntax solves? What are your ideas?

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