Anonymous user
Category:Smalltalk: Difference between revisions
→Control Structures
Line 461:
=== Control Structures ===
As mentioned above, these are defined as messages and their implementation is found in the corresponding receiver's class.
<br>Then, in the True class, define:▼
For illustration, here is how conditional execution ('if-then-else') is implemented in Smalltalk. There are two boolean objects named "true" and "false", which are singletons of corresponding classes named "True" and "False" (both inherit from Boolean, which inherits from Object). It is essential, that these are singletons, and that typical relational operators like "<", ">" etc. return one of those two.
<lang smalltalk>ifYouAreTrueThenDo: arg1 ifNotThenDo: arg2
^ arg1 value</lang>
|