I am learning Pharo online and am not sure if I got the syntax correct for creating class and instance variables. Please correct me if I am wrong :-
Class (Static) method created on class side of Pharo, where name, email, phone are instance variables of class CreateUser:
createNewUser:Arguments name:userName email:userEmail phone:userPhone
To call this static method of class CreateUser, I will do the following :-
CreateUser
name:userName
email:userEmail
phone:userPhone
If I want to create an instance variable by this name, the method declaration will be exactly the same as above, but it will be on the instance side of the class. However, when I call the method, I will call it using the keyword "new" to create a new instance as under:
CreateUser new
name:userName
email:userEmail
phone:userPhone
When I run the above code and call this method statically, I get an error message as:-
MessageNotUnderstood: CreateUser class >>name:email:phone:
However, when I go to the CreateUser class to recheck, I see the above method create on the class side as :
CreateUser:name:email:phone:
My queries are as below: 1. What am I doing wrong above? How can I fix the above error? 2. The concept behind using static variables/methods vs class variables/methods is the same as Java? 3. If I wish to access the above instance variables, I can add accessor methods for class/instance and then call them with the class instance/class object instance. Is that correct?
Any help you can give will be greatly appreciated! Thanks very much in advance.