如何在PlantUML活动图中实现continue语句功能
PlantUML循环中Continue逻辑的实现语法
在PlantUML的repeat循环里,要把原来的“Continue Loop”任务替换成真正的continue逻辑(跳过当前循环剩余步骤,直接进入下一轮循环判断),有两种简洁的实现方式:
方式一:使用跳转箭头指向循环判断节点
通过箭头直接将流程跳转到repeat while的条件判断位置,跳过后续任务:
@startuml start repeat :Task 1; if (Condition 1) then (Yes) :Task 2; else (No) ->[Continue] More Data?; endif if (Condition 2) then (Yes) :Task 3; else (No) ->[Continue] More Data?; endif repeat while (More Data?) is (Yes) not (No) end @enduml
方式二:直接使用continue关键字
PlantUML支持直接用continue;语句触发continue逻辑,语法更简洁,无需手动指定跳转目标:
@startuml start repeat :Task 1; if (Condition 1) then (Yes) :Task 2; else (No) continue; endif if (Condition 2) then (Yes) :Task 3; else (No) continue; endif repeat while (More Data?) is (Yes) not (No) end @enduml
两种方式都能实现相同效果:当条件不满足时,跳过当前循环的剩余任务,直接回到More Data?的判断环节,决定是否进入下一轮循环。
内容的提问来源于stack exchange,提问作者millie
相关产品推荐
相关产品推荐

