Creating a class in Pharo Smalltalk?

I follow an example of creating a class in Pharo at the following link: https://ci.inria.fr/pharo-contribution/job/UpdatedPharoByExample/lastSuccessfulBuild/artifact/book-result/PharoObjectModel/PharoObjectModel.html#class:flass

This is an example of creating a dog and a Hyena class. First I created a package called TestC, and in the instance class I did the following:

enter image description here

enter image description here

For what I know, and correct me if I am wrong, the instance side is where I create the methods that will work when I instantiate the object, and the class side does not need the object that will be created to work; as a class of static methods in Java.

, , - ! ?

, :

Dog class
    instanceVariableNames: 'count'

, , , :

enter image description here

, , , :

enter image description here

enter image description here

enter image description here

Transcript :

aDog := Dog new.
Dog count.
bDog := Dog new.
Dog count.

, , ( ), , ?

+4
1

! - . , ( ).

( ), . ,

Object subclass: #Dog
  instanceVariableNames: 'name breed birthdate'
  classVariableNames: ''
  package: 'TestC'

,

breed: aString
  breed := aString

dog := Dog new.
dog name: 'Taylor'; breed: 'Great Dane'

. , . , :

Dog class instaceVariableNames: 'count'

, Dog (a Metaclass), , , .

, Dog, count ivar Dog 1. , Dog . .

, ivar count initialize, increment retrieve . ? , . , ; , ( , , .)

+6

Source: https://habr.com/ru/post/1691543/


All Articles