SwitchByKind:
Filter:
Description
Class methods
new
Inherited class methods
Instance methods
init
value
Inherited instance methods
Classes (extension)
|
Libraries
>
crucial
>
utils
SwitchByKind
Extension
a switch statement that matches by class
Location:
NOT INSTALLED!
Description
This can efficiently replace a common and ugly series of if statements.
o = YetAnotherClass.new; if(o.isKindOf(SomeClass),{ // do something },{ if(o.isKindOf(AnotherClass),{ // do something },{ if(o.isKindOf(YetAnotherClass),{ // do something },{ // do something }) }) })
⧉
✔
k = SwitchByKind( SomeClass , { }, AnotherClass, { }, YetAnotherClass, { }, Object, { } ); o = YetAnotherClass.new; // finds the handler for YetAnotherClass result = k.value(o); // if SomethingDifferent is a subclass of AnotherClass n = SomethingDifferent.new; // it will find the handler for AnotherClass result = k.value(n);
⧉
✔
Class Methods
.
new
Arguments:
... pairs
Inherited class methods
Instance Methods
.
init
Arguments:
pairs
.
value
Arguments:
object
... args
Inherited instance methods
helpfile source:
/tmp/scquark_hs/crucial-library/HelpSource/Classes/SwitchByKind.schelp
link::Classes/SwitchByKind::