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

Demonstrate @switch with multiline block #181

Closed
wants to merge 2 commits into from

Conversation

jariji
Copy link
Contributor

@jariji jariji commented Feb 16, 2024

Closes #178

I guess the point of @switch is to make the RHS shorter when it has multiple statements.

Copy link

codecov bot commented Feb 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (fb9c79a) 61.52% compared to head (934b3a7) 61.52%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #181   +/-   ##
=======================================
  Coverage   61.52%   61.52%           
=======================================
  Files          28       28           
  Lines        1627     1627           
=======================================
  Hits         1001     1001           
  Misses        626      626           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@thautwarm
Copy link
Owner

I guess the point of @switch is to make the RHS shorter when it has multiple statements

This is 1/2 reason.

The second one is @switch pattern matching can create variables that can be accessed outside @switch itself.

julia> @switch [1, 2] begin
          @case [x, y]
       end

julia> x
1

julia> y
2

julia> @match [1, 2] begin
           [a, b] => nothing
       end

julia> a
ERROR: UndefVarError: `a` not defined

julia> b
ERROR: UndefVarError: `b` not defined

@jariji
Copy link
Contributor Author

jariji commented Feb 18, 2024

I see, it even says that already. I just missed it.

@jariji jariji closed this Mar 30, 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

Successfully merging this pull request may close these issues.

Show multiple @case expressions in the @switch docs
2 participants