DNess007
DNess007

Reputation: 41

How to Create Methods in Pharo

I am am new to programming and currently learning Pharo Smalltalk. However, I got to a part of the book I am using (LearningOOP) and I am stuck at "Adding a setter method". The exercise is to write the method count: such that when invoked on an instance of Counter, instance variable is set to the argument given to the message. Can anyone help please?

|c|
c := Counter new count: 7
c count 7
>>>7

Upvotes: 0

Views: 492

Answers (1)

bruno bb
bruno bb

Reputation: 152

In Counter class (instance side):

count: anInteger
   count := anInteger

Upvotes: 2

Related Questions