Thursday, 9 May 2024

PlantUML: keyword arguments

Functions, procedures can also be called using keyword arguments, i.e, by using argument names.

Example

!function $sum($a, $b)
	!global $counter = $counter + 1
	!return $a + $b
!endfunction

 

Above function can be called in following ways.

$sum($b=45, $a=5)
$sum($b=45, 5)
$sum(5, 45)

keywordArguments.txt

@startuml

!global $counter = 1

!function $sum($a, $b)
	!global $counter = $counter + 1
	!return $a + $b
!endfunction

sys1 -> sys2 : $counter. sum of 5 and 45 is $sum($b=45, $a=5)
sys1 -> sys2 : $counter. sum of 5 and 45 is $sum($b=45, 5)
sys1 -> sys2 : $counter. sum of 5 and 45 is $sum(5, 45)

@enduml

Above snippet generate below diagram.




 

  

Previous                                                    Next                                                    Home

No comments:

Post a Comment