Anonymous user
Category:Smalltalk: Difference between revisions
m
→A Word About Code Snippets in Rosetta
Line 511:
For example, if asked to provide an example for a factorial function, a typical Smalltalk solution would be to define a method in the Integer class called "factorial", which might look like the following naïve version:
<lang smalltalk>factorial
^ (self <= 1)
ifTrue:[1]
ifFalse:[ self * (self-1) factorial ]</lang>
(here 'self' is the Integer receiver object, and "ˆ" returns a value from the message send).
|