|
Smalltalk/X WebserverDocumentation of class 'Switch': |
|
|
Class: SwitchInheritance:Object | +--Switch
Description:
This class provides a switch-expression facility.
Consider this a demo example, nested if's are much more
efficient. However, support for inline switches may be added
to the compiler (as is done in Smalltalk-agents)
- in this case, a switch will be as efficient as any other if.
Beta Testers: Let me know if such a facility is useful and/or needed ...
example:
|a b|
a := 1.
b := 2.
(Switch new)
if:[a > b] then:['a is greater than b'];
if:[a < b] then:['a is less than b'];
otherwise:['a same as b'];
value
Class protocol:instance creationInstance protocol:cases evaluation initialization |
|
|
ST/X 6.1.1; WebServer 1.620 at exept:8081; Tue, 22 May 2012 22:31:27 GMT
|