plantuml - activity diagram: Decision node with three outgoing edges and [else] guard

Viewed 547

How can I design a Decision node with three outgoing edges and else guard?

what I'd like is - 3 outgoing edges from decision node 'test?'

enter image description here

@startuml

start
:dd;
if (test?) then (a)
  :A;
else if (b)
  :B;
else (c)
  :C;
endif
:wertz;
:dewe;
end

@enduml
3 Answers

For that you can use several else allowed by the 'old' syntax of activities :

@startuml
(*) --> if "" then
  --> [[priority = 1]] "A"
else
  --> [[priority = 2]] "B"
else
  --> [[else]] "C"
endif
@enduml

enter image description here

Note it is not possible to directly use ]] nor \]], both producing a syntax error, so I had to use ] to close the bracket

this is another solution proposed in the PlantUML Q&A: enter image description here

@startuml
start
switch (test?)
case ( condition A )
  :Text 1;
case ( condition B ) 
  :Text 2;
case ( condition C )
  :Text 3;
case ( condition D )
  :Text 4;
endswitch
stop
@enduml

A similar requirement for "Switch or multiple else branches" was discussed in the PlantUML Q&A, and they suggested the following approach which also worked for me:

@startuml
start
if (condition A) then (yes)
  :Text 1;
elseif (condition B) then (yes)
  :Text 2;
  stop
elseif (condition C) then (yes)
  :Text 3;
elseif (condition D) then (yes)
  :Text 4;
else (nothing)
  :Text else;
endif
stop
@enduml 
Related