REFERENCE · Pharo course
Reference Card
The whole language fits here. Everything else is objects and messages.
| Kind | Examples |
|---|---|
| Integer / Float | 42 -7 3.14 2r1010 "binary 10" |
| Fraction | 3/4 "a real Fraction, not 0.75" |
| Character | $A $z $ "dollar + one char" |
| String | 'hello' 'it''s' "double '' to escape" |
| Symbol | #count #+ "unique, interned" |
| Array (literal) | #(1 2 3 $a 'x' #sym) |
| Array (dynamic) | { 1+1. 2 factorial } "evaluated" |
| Boolean / nil | true false nil |
| Type | Shape | Example | Precedence |
|---|---|---|---|
| Unary | receiver selector | 5 factorial | 1st (tightest) |
| Binary | receiver op arg | 3 + 4 | 2nd |
| Keyword | recv k1: a1 k2: a2 | arr at: 1 put: 9 | 3rd (loosest) |
2 + 3 * 4 → 20. Use ( ) to override.
The selector of at:put: is the single name #at:put:.
| Symbol | Means | Example |
|---|---|---|
| := | assignment | count := 0 |
| . | statement separator | a := 1. b := 2 |
| ; | cascade — more messages to the same receiver | c increment; increment; reset |
| ^ | return from method | ^ count |
| "..." | comment | "this is a comment" |
| [ :x | ... ] | block (a closure); :x is a parameter | [ :x | x * x ] |
c increment; increment; count "cascade: 3 messages to c. Value = last = count"
c increment increment count "chain: count sent to (increment's result)"
A cascade’s receiver is the receiver of the first message before the first ;.
incrementBy: anInteger "selector + arg name = method header"
count := count + anInteger "body; no ^ means it returns self"
x > 0 ifTrue: [ 'pos' ] ifFalse: [ 'neg' ] "ifTrue:ifFalse: sent to a Boolean"
3 timesRepeat: [ Transcript show: 'hi' ]
#(1 2 3) do: [ :each | Transcript show: each printString ]
This card is the compressed form of Lesson 0001. Ask your teacher (Claude) to expand any row into practice.