[Forwarded to pharo-dev for side discussion...] On Sat, Dec 10, 2016 at 2:15 AM, Ben Coman <[email protected]> wrote: > On Sat, Dec 10, 2016 at 1:39 AM, Kateryna Aloshkina > <[email protected]> wrote: >> Hi everybody! >> >> I've just joined the community:) and have a question >> How 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? >> so that >> Counter new count: 7 >> would set the value of a new Counter instance to 7 >> (It is a little exercise from >> http://rmod-pharo-mooc.lille.inria.fr/MOOC/Exercises/Exo-Counter.pdf) >> >> >> Best wishes, >> Kateryna > > Welcome Kateryna, > I hope you are having fun and Pharo changes the way you think about > programming. > > Referring to Figure 1.2, assuming you've already created the class, > first make sure you are on the instance-side rather than the class-side > of the class such that the class definition in the bottom (code) pane > looks just like Figure 1.2. Click the <Class> button to toggle which > side you look at. > > Now in the third (protocols) pane on "no messages" > and you will get a method template in the code pane > > Change... messageSelectorAndArgumentNames > to... count: > > then change.... statements > to an assignment to the instance variable. > and <Accept> the the code to save & compile the method.
To be pedantic, shouldn't "no messages" actually be "no methods" But maybe even better would be... "click for method template" ? cheers -ben
