Modification Prevention Prefix Final

1 Simple Example

A variable declared as final in a member modification cannot be further modified by another modification. All members of a final member are also final, e.g. the fields of a final member that is a record are final.




2 Simulation of Angle

When we simulate the class AngleInst we see that there is an error, since we try to modify the unit which is declared as final. We also get a warning because a1 and a2 do not have any default values.



3 More Advanced Example

Here is another, slightly more advanced, example of the use of final. This example invovles a model that is used as a transfer function within a PI controller.






4 Instantiation of PI




We see in the instantiaten of Test that an error occurs because we try to modify b, which is declared as final.