Object subclass: #Point
instanceVariableNames: 'x y'
classVariableNames: ''
package: 'Graphics'
We send the message subclass:inst....
to the superclass to create the class
factorial
"Answer the factorial of the receiver."
self = 0 ifTrue: [ ^ 1 ].
self > 0 ifTrue: [ ^ self * (self - 1) factorial ].
self error: 'Not valid for negative integers'
In which class is factorial
defined?
In this lecture, a method will be displayed as
Integer >> factorial
"Answer the factorial of the receiver."
self = 0 ifTrue: [ ^ 1 ].
self > 0 ifTrue: [ ^ self * (self - 1) factorial ].
self error: 'Not valid for negative integers'
In Pharo, the method belongs to the selected class
Integer >> factorial
"Answer the factorial of the receiver."
self = 0 ifTrue: [ ^ 1 ].
self > 0 ifTrue: [ ^ self * (self - 1) factorial ].
self error: 'Not valid for negative integers'
factorial
is the method name=
, >
, *
and -
are binary messagesfactorial
is an unary messageifTrue:
and error:
are keyword messages^
is for returning a valueGame >> initializePlayers
self players
at: 'tileAction'
put: ( MITileAction director: self )
is equivalent to
Game >> initializePlayers
self players
at: 'tileAction'
put: ( MITileAction director: self ).
^ self "<-- optional"
class
to define a class methodclass
Point class >> x: xInteger y: yInteger
"Answer an instance of me with coordinates xInteger and yInteger."
^ self basicNew setX: xInteger setY: yInteger
self
/