Closed
Description
I think it would be a good addition to have versions of @trymatch
and @tryswitch
that allow having no matches, like for example
@trymatch x begin
::Int => :int
end
# would be equivalent to
@match x begin
::Int => :int
_ => nothing
end
and
@tryswitch x begin
@case ::Int
println("int")
end
# would be equivalent to
@switch x begin
@case ::Int
println("int")
@case _
nothing
end
The main advantage with these is when you have nested @match
and @switch
statements, where each invocation will require adding this special case for no matches. The name should make it fairly obvious that it will silently "fail".
If it's not already implemented (I looked around, but we never know) I can submit a PR to define these helper macros.
Activity