Smalltalk variables: why should I declare them?
问题 Basically I can use variables just by assigning something to them, for example: x := something It works fine. But in classes, if I define a new method, but I don't declare the variable, I get an "assignment to undeclared variable x", so I have to use: |x| x := something Why is this? 回答1: As Uko mentions, there are different kinds of variables in Smalltalk and that's why we need to declare them differently. Let's review all of Smalltalk variables here for the sake of completeness. Instance