Download the PBE-OneClick, and started my way through it
ProfStef lessons 1st, then Pharo By Example, the book
Highlight text in the workspace and Alt-p or rt-click to "print it", and the expression is evaluated, then printed to the workspace.
It stays highlighted, so it is easy to then delete or backspace
Highlight text in the workspace and Alt-d to "do it". Expression is evaluated.
Unary - one argument following an object
Binary one argument between two objects
Keyword - as many arguments as you like, each with a keyword preceding it.
Each keyword is suffixed by a colon. e.g. Gordon middleName: 'Reynolds' lastName: 'Love'.
. (full stop) completes an expression
Precedence: Unary then binary then keyword, left to right when of equal precedence
Always - even for arithmetic expressions.
Parentheses alter the precedence order
If you end an expression with ; (rather than . ), the subject of the next line is left implicit, and it will be the same as the subject of the line just ended. This is called a message cascade.
Transcript show: 'hello'.
Transcript show: 'Smalltalk'.
"is equivalent to:"
show: 'Smalltalk' ;
anonymous methods that can be
stored as variables and
executed on demand
delimited by square brackets [ ]
Here is a block that adds 2 to its argument (its argument is named x):" :x is, in effect, also the local variable.
[:x | x+2].
"We can execute a block by sending it value messages."
[:x | x+2] value: 5.
[Browser open] value.
[:x | x+2] value: 10.
[:x :y| x + y] value:3 value:5.
Declare a variable, enclose it in | | e.g.
Blocks can be assigned to a variable, and executed later
b := [:x | x+2].
b value: 12.
Sends '12' into b, which is an object which takes its input and adds 2 to it.
Transcripts are little workpads on the screen
Conditionals - messages sent to boolean objects
3 > 10
ifTrue: [Transcript show: 'maybe there''s a bug ....']
ifFalse: [Transcript show: 'No : 3 is less than 10'].