## Variables
```smalltalk
startPoint "a variable name"
Transcript "a global variable name"
self "pseudo-variable"
```
## Other Declarations and Expressions
```smalltalk
| x y | "declaration of variables x and y"
x := 1 "assign 1 to x"
[ x + y ] "a block that evaluates to x+y"
<primitive: 1> "virtual machine primitive or annotation"
```
## Messages
```smalltalk
3 factorial "unary message"
3+4 binary "messages"
2 raisedTo: 6 modulo: 10 "keyword message"
```
## Blocks
```smalltalk
[ 1 + 2 ] value "3"
[ :x | 1 + x ] value: 2 "3"
[ :x :y | x + y ] value: 1 value: 2 "3"
[ :x :y | | z | z := x+ y. z ] value: 1 value: 2 "3"
```
Closure
```smalltalk
| x |
x := 1.
[ :y | x + y ] value: 2 "3"
```
## Conditional and Loops
```smalltalk
(17 * 13 > 220)
ifTrue: [ 'bigger' ]
ifFalse: [ 'smaller' ] "bigger"
```
```smalltalk
n := 1.
[ n < 1000 ] whileTrue: [ n := n*2 ].
n "1024"
```
```smalltalk
n := 1.
[ n > 1000 ] whileFalse: [ n := n*2 ].
n "1024"
```
```smalltalk
n := 1.
10 timesRepeat: [ n := n*2 ].
n "1024"
```
Smalltalk Object Model
## The Rules
- Rule 1. Everything is an object.
- Rule 2. Every object is an instance of a class.
- Rule 3. Every class has a superclass.
- Rule 4. Everything happens by sending messages.
- Rule 5. Method lookup follows the inheritance chain.
## Every object is an instance of a class
```smalltalk
1 class "SmallInteger"
20 factorial class "LargePositiveInteger"
'hello' class "ByteString"
#(1 2 3) class "Array"
(4@5) class "Point"
Object new class "Object"
```
## The instance side and the class side
```smalltalk
aColor := Color blue. "Class side method blue"
aColor "Color blue"
aColor red "0.0 Instance side accessor method red"
aColor blue "1.0 Instance side accessor method blue"
```