Jump to content

Category:Smalltalk: Difference between revisions

Line 394:
 
=== Control Structures ===
As mentioned above, these are defined as messages and their implementation is found in the corresponding receiver classes. 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 thesethose two.
<br>Then, in the True class, define a method:
<lang smalltalk>True
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.