[Oberon] CASE without ELSE
andreas_pirklbauer at yahoo.com
Sun Feb 18 22:37:02 CET 2018
> > Does it mean that CASE statement for pointer/
> > record types work like an IF statement?
> Yes, it is a syntactic sugar for IF/ELSIF
> and type guard, nothing more.
A key difference to the IF statement
IF t IS T1 THEN S1
ELSIF t IS T2 THEN S2
is that in the CASE statement
CASE t OF
T1: S1 |
T2: S2 |
the dynamic type t of the case expression is set to the type of the selected case, i.e. in the statements S1 labeled by T1, the case variable t is considered as of type T1, etc.
This implies that no type guard t(T1) is needed in S1, etc, i.e. one can just write t instead.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Oberon