This exercise is about reading and understanding Pharo expressions, and differentiating between different types of messages and receivers.
Note that in the expressions you will be asked to read and executed, you
can assume that the implementation of methods generally corresponds to what their message names imply (i.e., 2 + 2 = 4
).
In addition, most of the expressions we use in the exercises are expressions that you can execute in Pharo, so do not hesitate.
What kind of object does the following literal expressions refer to?
'Hello, Dave'
Solution.
a string
1.3
Solution.
a float
#node1
Solution.
a symbol (unique string)
#(2 33 4)
Solution.
an array
[ :each | each scale: 1.5 ]
Solution.
a block (lexical closure)
$A
Solution.
a character
true
Solution.
a boolean
1
Solution.
a smallinteger
For each of the expressions below, fill in the answers:
3 + 4
Solution.
receiver: 3
selector: +
argument: 4
Date today
Solution.
receiver: Date
selector: today
argument: none
anArray at: 1 put: 'hello'
Solution.
receiver: anArray
selector: at:put:
argument: 1 and 'hello'
anArray at: i
Solution.
receiver: anArray
selector: at:
argument: i
#(2 33 -4 67) collect: [ :each | each abs ]
Solution.
receiver: #(2 33 -4 67)
selector: collect:
argument: [ :each | each abs ]
25 @ 50
Solution.
receiver: 25
selector: @
argument: 50
SmallInteger maxVal
Solution.
receiver: SmallInteger
selector: maxVal
argument: none
#(a b c d e f) includesAll: #(f d b)
Solution.
receiver: #(a b c d e f)
selector: includesAll:
argument: #(f d b)
true | false
Solution.
receiver: true
selector: |
argument: false
Point selectors
Solution.
receiver: Point
selector: selectors
argument:
Transferator
?
Transferator
is a global variable: either a class, a global variable or a class variable.
Solution.
rectangle
?
Solution.
rectangle
is a local variable: either a temporary, an instance variable, or a method argument.