Sitemap | Search || Zen Spider Website
/ The Language Freak
/ Smalltalk
/ A Brief Tutorial of Smalltalk
A Brief Tutorial of Smalltalk
Smalltalk is a wonderful and simple language. It is incredibly easy to learn.
Let's start with the most rudimentary basics. I will assume that you are
running Squeak or a VisualWorks derivative, or something that simply acts
like one of these two.
- Open up a transcript or workplace window.
- In that window, type:
| var |
var := 42.
var
- Now select this code and either select the menu item for "inspect it", or
- hit the command key for it (cmd-i most likely). An instance browser
- will pop up that represents the current value of var, 42. In this browser,
- you may see a few things including, the class of the instance, all instance
- variables (in this case, just the value 42, but with more complex instances,
- you'd see each and every variable).
- You can also invoke the code using "print it" or "run it". All three run
- the code, but "inspect it" brings up a browser, "print it" prints the textual
- representation of it, and "run it" has no side effects (that you didn't code
- yourself).
- Now change the right hand side of the assignment to be "42" instead of 42
- and inspect it again. Get a feel for the browser.
- So far, you haven't invoked any actual methods in your code, you've only
- been dealing with the most primative smalltalk possible (the assignment, and
- a basic reference, both of which are just bytecodes). Now we are going to
- start doing some things with these objects, and that will require invoking
- their instance methods.
- Change the code so that the reference ("var" at the end) calls the "charAt:"
- method (referred to by smalltalkers as #charAt:) and pass it the argument of 1.
- Try to guess what you will get as a response, and inspect the result.
- The code should read:
| var |
var := "42".
var charAt: 1
TODO: finish
Sitemap | Search || Zen Spider Website
/ The Language Freak
/ Smalltalk
/ A Brief Tutorial of Smalltalk