I have a unit my_unit
with a boolean field my_bool
. I need to add a specific logic to my_unit
when my_bool == FALSE
. Is it possible?
unit my_unit {
my_bool : bool;
when my_bool {
// Works fine, I can add logic to my_unit
};
when not my_bool {
// This causes compilation error!!!
// Here I need to add another logic
};
};
Is there a way to do it? Thank you for your help
The compiler seems to be treating when my_bool
as when TRUE'my_bool
. If you want to write code for the when
the variable is FALSE
, you can write:
unit my_unit {
// ...
when FALSE'my_bool {
// ...
};
};