You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
julia> @enum State beg init final stop pass
julia> for state in instances(State)
if state == beg; println("start")
elseif state == init; println("initiate")
elseif state == final; println("terminate")
elseif state == stop; println("end")
else println("never")
end @match state begin
beg => println("111")
init => println("222")
final => println("333")
stop => println("444")
never => println("555")
end
end
Output:
start
111
initiate
111
terminate
111
end
111
never
111
The text was updated successfully, but these errors were encountered:
A pattern that is a simple name matches any input and binds the input to that name. If you want a name to be treated as an expression, you need to escape it. In version 2 of this package, here is the behavior:
julia> Pkg.status()
Status `~/.julia/environments/v1.6/Project.toml`
[7eb4fadd] Match v2.0.0
julia> @enum State beg init final stop pass
julia> for state in instances(State)
if state == beg; println("start")
elseif state == init; println("initiate")
elseif state == final; println("terminate")
elseif state == stop; println("end")
else println("never")
end
@match state begin
$beg => println("111")
$init => println("222")
$final => println("333")
$stop => println("444")
never => println("555")
end
end
start
111
initiate
222
terminate
333
end
444
never
555
I don't understand the following behavior:
julia> @enum State beg init final stop pass
julia> for state in instances(State)
if state == beg; println("start")
elseif state == init; println("initiate")
elseif state == final; println("terminate")
elseif state == stop; println("end")
else println("never")
end
@match state begin
beg => println("111")
init => println("222")
final => println("333")
stop => println("444")
never => println("555")
end
end
Output:
start
111
initiate
111
terminate
111
end
111
never
111
The text was updated successfully, but these errors were encountered: