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

head body... tail match #64

Closed
xiaodaigh opened this issue Sep 24, 2020 · 1 comment
Closed

head body... tail match #64

xiaodaigh opened this issue Sep 24, 2020 · 1 comment

Comments

@xiaodaigh
Copy link

using Match

@match
([1:4], [a,b...,c])

I was hoping a = 1, b = [2, 3] and c = 4. Python has an unpacking feature similar to this.

@gafter
Copy link
Member

gafter commented Aug 3, 2023

The expression [1:4] is an array containing a single element, which is a range. Perhaps you meant the following?

julia> Pkg.status()
      Status `~/.julia/environments/v1.6/Project.toml`
  [7eb4fadd] Match v2.0.0

julia> using Match

julia> @ismatch 1:4 [a, b..., c]
true

julia> a
1

julia> b
2:3

julia> c
4

@gafter gafter closed this as completed Aug 3, 2023
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