The article was written to be concise and easy to read, and to focus on one key message. It was not intended to show Smalltalk in nitty-gritty detail.
If the reader was inspired by it, they could do their own research. Google is their friend.
It’s easy for an article like this to be crammed full of details and to meander all over the place. I like to always focus the reader’s attention on one or two key ideas.
But since you ask, here are some examples:
"Compute difference in days between two dates"
('2014–07–01' asDate — '2013/2/1' asDate) days
"Decimal digit length of 42!"
42 factorial decimalDigitLength
"Set up an HTTP server that returns the current timestamp"
(ZnServer startDefaultOn: 8080)
onRequestRespond: [ :request |
ZnResponse ok: (ZnEntity with: DateAndTime now printString) ]
"Split a string on dashes, reverse the order of the elements and join them using slashes"
$/ join: ($- split: '1969–07–20') reverse
"Extract a Unix format timestamp from the 5th to 8th byte of a byte array given in hex"
DateAndTime fromUnixTime:
((ByteArray readHexFrom: 'CAFEBABE4422334400FF')
copyFrom: 5 to: 8) asInteger
"Generate a random string"
(String new: 32) collect: [ :each | 'abcdef' atRandom ]
"Return the weekday of a date"
'2013/5/7' asDate dayOfWeekName
"Save the HTML source of a web page to a file"
'http://www.pharo.org' asUrl saveContentsToFile: 'page.html'
"Count the number of, or show the leap years between two years"
(1914 to: 1945) count: [ :each | Year isLeapYear: each ].
(1895 to: 1915) select: [ :each | Year isLeapYear: each ].
"Encode the same string using Latin1, UTF-8 and UTF-16"
#(latin1 utf8 utf16) collect: [ :each |
(ZnCharacterEncoder newForEncoding: each)
encodeString: 'Les élèves Français' ]
The key thing to understand here is that Smalltalk syntax is based almost entirely on one concept: passing messages to objects. This includes the traditional logical control structures like if statements and loops, for example:
x < 100 ifTrue: [Transcript crShow: 'is less than 100']
ifFalse: [Transcript crShow: 'is at least 100'].
Here, the result of x < 100, which is a Boolean object, is sent the message #ifTrue:ifFalse:. Incidentally, the square brackets delineate code blocks, which in Smalltalk are actually lambda objects.
Since all Smalltalk messages are unary, binary, or keyword (taking on arguments), the above examples represent all Smalltalk code bases.