Smalltalk Cheatsheet Triptico PDF
Smalltalk Cheatsheet Triptico PDF
#(1 2 3 4)
inject: 0 " ReadStream – to read a sequence of objects from a collection
into: [ :each :result | each + result ] −→ 10 "
stream := 'Hello World' readStream. Smalltalk Cheat Sheet
" testing " stream next −→ $H
#( 2 4 ) anySatisfy: [ :each | each odd ] −→ false stream upTo: $o −→ 'ell'
#( 2 4 ) allSatisfy: [ :each | each even ] −→ true stream skip: 2. Software Composition Group
stream peek −→ $o University of Bern
" finding " stream upToEnd −→ 'orld'
'abcdef' includes: $e −→ true May 21, 2008
'abcdef' contains: [ :each | each isUppercase ] −→ false " WriteStream – to write a sequence of objects to a collection "
'abcdef' stream := WriteStream on: Array new.
detect: [ :each | each isVowel ] stream nextPut: 'Hello'.
ifNone: [ $u ] −→ $a stream nextPutAll: #( 1 2 3 ).
stream contents −→ #( 'Hello' 1 2 3 ) 1. The Environment
" String – a collection of characters "
string := 'abc'. File Streams 1. class categories 2. classes 4. method protocols 5. methods
string := string , 'DEF' −→ 'abcDEF'
string beginsWith: 'abc' −→ true fileStream := FileDirectory default newFileNamed: 'tmp.txt'.
string endsWith: 'abc' −→ false fileStream nextPutAll: 'my cool stuff'.
string includesSubString: 'cD' −→ true fileStream close.
string asLowercase −→ 'abcdef
string asUppercase −→ 'ABCDEF' fileStream := FileDirectory default oldFileNamed: 'tmp.txt'.
fileStream contents −→ 'my cool stuff'
" OrderedCollection – an ordered collection of objects "
ordered := OrderedCollection new. Method Definition
ordered addLast: 'world'.
messageSelectorAndArgumentNames
ordered addFirst: 'hello'.
"comment stating purpose of message"
ordered size −→ 2 3. instance-, class-side,
| temporary variable names |
ordered at: 2 −→ 'world' comments
statements
ordered removeLast −→ 'world'
ordered removeFirst −→ 'hello' 6. source code
ordered isEmpty −→ true Class Definition (CMD–S) to save and compile