Literals
3 class
$a class
'string' class
#(1 2 3) class
1 + "This is a comment" 3.
[ :argument |
	| localVariable1 localVariable2 |
	argument * argument.
] class

Expressions
3 factorial
3 + 2
#(1 2) = #(1 2)
#(1 2) == #( 1 2)
3 min: 2
(1 to: 11 by: 2) class

Statements
[ ^3. 'hello'. ] value
a := 4.
a
(OrderedCollection with: 1 with: 2)
	add: 3;
	remove: 1;
	yourself.
[ :anInteger | 3 + anInteger. ] value: 5

Control flow
3 = 3 ifTrue: [ 'true' ]
3 = 4 ifFalse: [ 'false' ]
3 = 4 ifTrue: [ 'true' ] ifFalse: [ 'false' ]
	| i |
	 i := 0.
	[ i := i + 1. i < 10. ] whileTrue.
	i.

	| i j |
	i := 0.
	j := 0.
	[ i := i + 1. i < 10. ] whileTrue: [
		j := i.
	].
	j.

	| sum |
	sum := 0.
	#(1 2 3) do: [ :each |
		sum := sum + each.
	].
	sum.

	| sum |
	sum := 1.
	[ sum := sum + sum. sum > 10000 ifTrue: [ self halt ] ] repeat.

	| sum |
	sum := 1.
	5 timesRepeat: [ sum := sum + sum ].
	sum.

	"Load Switch package."
	Switch example

Exceptions
3 subtract
[ 3 subtract ] on: Error do: [ :error | 5 ].

Order of evaluation
2 negated + 3 negated + 4 negated to: 3 negated do: [ :i | ^5 ].

Exercises
Control flow
books := #('Book1' 'Book2' 'Book3').
authors := #('Author1' 'Author2' 'Author3').
1 to: books size do: [ :index |
	Transcript
		nextPutAll: 'Book: ';
		nextPutAll: (books at: index);
		nextPutAll: ' Author: ';
		nextPutAll: (authors at: index);
		cr;
		yourself.
].

books := #('Book1' 'Book2' 'Book3').
authors := #('Author1' 'Author2' 'Author3').
books before: authors do: [ :each |
	Transcript nextPutAll: each; cr.
].

books := #('Book1' 'Book2' 'Book3').
authors := #('Author1' 'Author2' 'Author3').
books beside: authors do: [ :book :author |
	Transcript
		nextPutAll: 'Book: ';
		nextPutAll: book;
		nextPutAll: ' Author: ';
		nextPutAll: author;
		cr;
		yourself.
].

#(1 2) beside: #(3) do: [ :left :right | 3. ]

[ #(1 2) beside: #(3) do: [ :left :right | 3. ] ] on: Error do: [ :error | 4 ].

Exercises
FizzBuzz
1 to: 100 do: [ :i |
	(i % 5 = 0 and: [ i % 7 = 0 ]) ifTrue: [	
		Transcript show: 'fizzbuzz'.
	] ifFalse: [
		i % 5 = 0 ifTrue: [
			Transcript show: 'fizz'.
		] ifFalse: [
			i % 7 = 0 ifTrue: [
				Transcript show: 'buzz'.
			] ifFalse: [
				Transcript show: i displayString.
			].
		].
	].
	Transcript show: ' '.
].
Transcript cr.

FizzBuzz run.

fizzbuzz := HiddenFizzBuzz1 new.
fizzbuzz displayString
fizzbuzz next
fizzbuzz displayString
fizzbuzz next
fizzbuzz next
fizzbuzz next
fizzbuzz displayString
fizzbuzz next
fizzbuzz next
fizzbuzz displayString

fizzbuzz := HiddenFizzBuzz2 new.
fizzbuzz displayString.
fizzbuzz next
fizzbuzz displayString
fizzbuzz next
fizzbuzz next
fizzbuzz next
fizzbuzz displayString
fizzbuzz next
fizzbuzz next
fizzbuzz displayString

HiddenFizzBuzzPresenter show

Applications
MutsunParserDialog showOn: MutsunParserDialog testModel
SpellTrainerDialog showTrainedExamples
SpellTrainerDialog showUntrainedExamples
"Do ReadSmartOptions from exe" 
EquationGamePresenter show

Package HiddenDevSIG

Class hierarchy
Object
	Collection
		SequenceableCollection
	HiddenFizzBuzzes
		HiddenFizzBuzz1
		HiddenFizzBuzz2
	Presenter
		Shell
			Dialog
				UnbufferedDialog
					HiddenFizzBuzzPresenter
	SessionManager
		GUISessionManager
			RuntimeSessionManager
				HiddenFizzBuzzSessionManager
Loose methods
Collection>>after: aCollection do: aBlock

	aCollection before: self do: aBlock.

Collection>>before: aCollection do: aBlock

	self do: aBlock.
	aCollection do: aBlock.

Collection>>hiddenAfter: aCollection do: aBlock

	aCollection hiddenBefore: self do: aBlock.

Collection>>hiddenBefore: aCollection do: aBlock

	self do: aBlock.
	aCollection do: aBlock.

SequenceableCollection>>beside: aSequenceableCollection do: aDyadicBlock

	self size ~= aSequenceableCollection size ifTrue: [
		self error: 'Collection sizes don''t match!'.
	].
	1 to: self size do: [ :index |
		aDyadicBlock value: (self at: index) value: (aSequenceableCollection at: index).
	].

SequenceableCollection>>hiddenBeside: aSequenceableCollection do: aDyadicBlock

	1 to: self size do: [ :index |
		aDyadicBlock value: (self at: index) value: (aSequenceableCollection at: index).
	].

HiddenFizzBuzz1
Definition
HiddenFizzBuzzes subclass: #HiddenFizzBuzz1
	instanceVariableNames: 'index'
	classVariableNames: ''
	poolDictionaries: ''
	classInstanceVariableNames: ''
Class methods
new

	^self basicNew initialize.

run

1 to: 100 do: [ :i |
	(i % 5 = 0 and: [ i % 7 = 0 ]) ifTrue: [	
		Transcript show: 'fizzbuzz'.
	] ifFalse: [
		i % 5 = 0 ifTrue: [
			Transcript show: 'fizz'.
		] ifFalse: [
			i % 7 = 0 ifTrue: [
				Transcript show: 'buzz'.
			] ifFalse: [
				Transcript show: i displayString.
			].
		].
	].
	Transcript show: ' '.
].
Transcript cr.
Instance methods
displayString

	| i |
	i := index.
	(i % 5 = 0 and: [ i % 7 = 0 ]) ifTrue: [	
		^'fizzbuzz'.
	] ifFalse: [
		i % 5 = 0 ifTrue: [
			^'fizz'.
		] ifFalse: [
			i % 7 = 0 ifTrue: [
				^'buzz'.
			] ifFalse: [
				^i displayString.
			].
		].
	].

initialize

	super initialize.
	index := 1.
	^self.

next

	index := index + 1.

HiddenFizzBuzz2
Definition
HiddenFizzBuzzes subclass: #HiddenFizzBuzz2
	instanceVariableNames: 'index multiplesOf5 multiplesOf7'
	classVariableNames: ''
	poolDictionaries: ''
	classInstanceVariableNames: ''
Class methods
new

	^self basicNew initialize.
Instance methods
displayString

	(index = multiplesOf5 current and: [ index = multiplesOf7 current ]) ifTrue: [	
		^'fizzbuzz'.
	].
	index = multiplesOf5 current ifTrue: [
		^'fizz'.
	].
	index = multiplesOf7 current ifTrue: [
		^'buzz'.
	].
	^index displayString.

initialize

	super initialize.
	index := 1.
	multiplesOf5 := Multiples of: 5.
	multiplesOf7 := Multiples of: 7.
	^self.

next

	index := index + 1.
	index > multiplesOf5 current ifTrue: [
		multiplesOf5 next.
	].
	index > multiplesOf7 current ifTrue: [
		multiplesOf7 next.
	].

HiddenFizzBuzzes
Definition
Object subclass: #HiddenFizzBuzzes
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	classInstanceVariableNames: ''
Class methods

Instance methods

HiddenFizzBuzzPresenter
Definition
UnbufferedDialog subclass: #HiddenFizzBuzzPresenter
	instanceVariableNames: 'fizzBuzzPresenter'
	classVariableNames: ''
	poolDictionaries: ''
	classInstanceVariableNames: ''
Class methods
defaultModel

	^HiddenFizzBuzz2 new.
Instance methods
cmdNext

	model next.
	fizzBuzzPresenter value: model displayString.

createComponents

	super createComponents.
	fizzBuzzPresenter := self add: TextPresenter new name: 'txtFizzBuzz'.

onViewOpened

	super onViewOpened.
	fizzBuzzPresenter value: model displayString.

HiddenFizzBuzzSessionManager
Definition
RuntimeSessionManager subclass: #HiddenFizzBuzzSessionManager
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	classInstanceVariableNames: ''
Class methods
mainShellClass

	^HiddenFizzBuzzPresenter.
Instance methods
main

	self mainShellClass show.

Package HiddenDevSIGTest

Class hierarchy
Object
	TestCase
		HiddenFizzBuzzTest
Loose methods

HiddenFizzBuzzTest
Definition
TestCase subclass: #HiddenFizzBuzzTest
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	classInstanceVariableNames: ''
Class methods

Instance methods
testIt

	| fizzBuzz |
	fizzBuzz := HiddenFizzBuzz2 new.
	1 to: 100 do: [ :index |
		| string |
		string := fizzBuzz displayString.
		index = 5 ifTrue: [
			self assert: string = 'fizz'.
		].
		index = 7 ifTrue: [
			self assert: string = 'buzz'.
		].
		index = 35 ifTrue: [
			self assert: string = 'fizzbuzz'.
		].
		string ~= index displayString ifTrue: [
			self assert: (index % 5 = 0 or: [ index % 7 = 0 ]).
		].
		fizzBuzz next.
	].