100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Smalltalk Cheat Sheet

Smalltalk Cheat Sheet

Foundational Smalltalk syntax covering message sends, class definitions, block-based conditionals and loops, and common collection operations.

1 PageIntermediateApr 10, 2026

Basic Syntax & Messages

Variables and the three kinds of message sends.

smalltalk
"Comments are written in double quotes"| x y |x := 5.y := 10.Transcript showCr: 'Hello, World!'.3 factorial.        "unary message"3 + 4.               "binary message"3 max: 4.            "keyword message"(3 + 4) * 2.          "parentheses control evaluation order"

Class Definition

Defining a class and adding methods.

smalltalk
Object subclass: #Animal    instanceVariableNames: 'name sound'    classVariableNames: ''    package: 'MyApp'.Animal >> makeSound    Transcript showCr: name, ' says ', sound.Animal >> name: aName sound: aSound    name := aName.    sound := aSound.

Conditionals & Loops (Blocks)

Control flow is implemented as messages that take blocks.

smalltalk
(x > 0)    ifTrue: [Transcript showCr: 'positive']    ifFalse: [Transcript showCr: 'not positive'].1 to: 5 do: [:i | Transcript showCr: i printString].[x < 10] whileTrue: [x := x + 1].

Collections

Working with OrderedCollection and blocks-as-callbacks.

smalltalk
| coll |coll := OrderedCollection new.coll add: 1; add: 2; add: 3.coll do: [:each | Transcript showCr: each printString].(coll collect: [:each | each * each]) printNl.(coll select: [:each | each > 1]) printNl.
Pro Tip

Everything in Smalltalk, including True, False, and even classes themselves, is an object that responds to messages — there are no special-cased keywords, so `ifTrue:ifFalse:` is just an ordinary message sent to a Boolean.

Was this cheat sheet helpful?

Explore Topics

#Smalltalk#SmalltalkCheatSheet#Programming#Intermediate#BasicSyntaxMessages#ClassDefinition#ConditionalsLoopsBlocks#Collections#OOP#DataStructures#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech

Professional Web Designing Services

  • Responsive Websites
  • E-commerce Solutions
  • SEO Friendly Design
  • Fast & Secure
  • Support & Maintenance
Get a Free Quote

Share this Cheat Sheet