11.5.2 Branching with case
Dylan also provides the case control structure to give you an alternative way to express the branching style shown in Section 11.5.1:
define method interpret-votes
(#key yes :: <nonnegative-integer> = 0, no :: <nonnegative-integer> = 0)
=> (interpretation :: <string>)
case (yes > 0 & no = 0) => "unanimously approved";
(yes > no) => "approved";
(yes = no) => "tie";
otherwise => "not approved";
end case;
end method interpret-votes;
The decision of whether to use if with elseif and else, as opposed to using case, is largely a matter of personal style.




