Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Refactoring if-chains in Smalltalk without class explosion
- self condition1
- ifTrue: [ self actionForCondition1 ]
- ifFalse: [
- self condition2
- ifTrue: [ self actionForCondition2 ]
- ifFalse: [
- self condition3
- ifTrue: [ self actionForCondition3 ]
- ifFalse: [ .... ] ] ]
- anObject isKindOf: aClass
- anObject = anotherObject
- self condition1
- ifTrue: [ ^ self actionForCondition1 ].
- self condition2
- ifTrue: [ ^ self actionForCondition2 ].
- self condition3
- ifTrue: [ ^ self actionForCondition3 ].
- ...
- selector = selector1 ifTrue: [ invoke method1 ]
- ifFalse: [ selector= selector2 ifTrue: [ invoke method2 ]
- ifFalse: [...] ]]].
Add Comment
Please, Sign In to add comment