eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Switch':

Home

everywhere
www.exept.de
for:
[back]

Class: Switch


Inheritance:

   Object
   |
   +--Switch

Package:
stx:libcomp
Category:
Programming-Support
Version:
rev: 1.6 date: 1996/11/11 21:54:08
user: stefan
file: Switch.st directory: libcomp
module: stx stc-classLibrary: libcomp

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 creation
o  new


Instance protocol:

cases
o  if: expr then: block

o  otherwise: block

evaluation
o  value

initialization
o  initialize



ST/X 6.1.1; WebServer 1.620 at exept:8081; Tue, 22 May 2012 22:31:27 GMT