[Forwarded to pharo-dev for side discussion...]
On Sat, Dec 10, 2016 at 2:15 AM, Ben Coman <[hidden email]> wrote: > On Sat, Dec 10, 2016 at 1:39 AM, Kateryna Aloshkina > <[hidden email]> 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 |
To be pedantic it should be "no protocols" because as soon as you add one, you get --all-- someaddedprotocol even if there is no method. Phil On Fri, Dec 9, 2016 at 7:21 PM, Ben Coman <[hidden email]> wrote: [Forwarded to pharo-dev for side discussion...] |
In reply to this post by Ben Coman
> > To be pedantic, shouldn't "no messages" actually be "no methods" > But maybe even better would be... "click for method template" ? send a fix :) > > cheers -ben > -- Using Opera's mail client: http://www.opera.com/mail/ |
In reply to this post by philippeback
Nope. I'll see your pedantic, and raise you...
Clicking on "no messages" and adding a method you get... --all-- as yet unclassified. So "no protocols" goes away, but there are still no protocols. (pedantic poker, fun for all the family) cheers -ben On Sat, Dec 10, 2016 at 2:56 AM, [hidden email] <[hidden email]> wrote: > To be pedantic it should be "no protocols" because as soon as you add one, > you get > > --all-- > someaddedprotocol > > even if there is no method. > > Phil > > On Fri, Dec 9, 2016 at 7:21 PM, Ben Coman <[hidden email]> wrote: >> >> [Forwarded to pharo-dev for side discussion...] >> >> On Sat, Dec 10, 2016 at 2:15 AM, Ben Coman <[hidden email]> wrote: >> > On Sat, Dec 10, 2016 at 1:39 AM, Kateryna Aloshkina >> > <[hidden email]> 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 >> > |
Hi Ben, Yes and no. Because you can add a protocol right away without any method and end up in my layout. Pedantically yours, Phil On Sat, Dec 10, 2016 at 2:17 PM, Ben Coman <[hidden email]> wrote: Nope. I'll see your pedantic, and raise you... |
I will add that I doubt that any filetree repository (or at least its metadata-less versions) repository is capable of remembering an empty protocol.
2016-12-10 20:27 GMT+01:00 [hidden email] <[hidden email]>:
|
Free forum by Nabble | Edit this page |