Sends the "to:" message to the number 1 with the parameter 10. Returns a range representing the numbers from 1 to 10. You can then iterate that range with by sending it the "do:" message with a block argument.
1 to: 10 do:[ :i | <do something with i> ].
And so on. Looks a lot like syntax for a for-loop, but is just message sends to collections with keyword syntax. Every type of collection implements do: (and collect:, select:, reject: etc.) Conditionals work the same way:
1 > 0 ifTrue: [ <do something here> ]
Sends the ifTrue: message to the result of 1 >0. This will be the true object, which is the sole instance of the True class (subclass of Boolean). The True class defines ifTrue: so that it executes the block. Conversely, the False class defines ifTrue: so that it does nothing, ignoring the block.
The fact that what is usually syntax is just message sends means that you can define your own messaging protocols in libraries that also look like syntax.
Yes, I left that detail out for pedagogical purposes.
As the other respondent wrote, it still works the same way but with parentheses, and the to:do: exists as a convenience.
In Objective-Smalltalk[1], I added | so you can do this without parenthesis:
(1 to:10) do: [ :i | stdout println:i. ].
can become:
1 to:10 | do: [ :i | stdout println:i ].
This is nice when you are constructing a statement interactively, for example on a command line and don't want to go back. It also makes things less convoluted when the chain gets longer. It also "fixes" the asymmetry that chaining works with unary messages but not with keyword messages.
Of course, the whole thing becomes even more elegant, IMHO, with a Higher Order Message (HOM)[2]:
The fact that what is usually syntax is just message sends means that you can define your own messaging protocols in libraries that also look like syntax.
Dan Ingalls explains: https://youtu.be/P2mh92d-T3Y?t=574
Also, the Grace language expands on this concept by allowing effectively regular expressions of these keyword parameters. Really quite nifty.