How to add a new method in Pharo?












1














In the Nautilus System Browser (Pharo 6) there's a right-click command to Add package... as well as Add class... and even Add protocol..., but I can't find anywhere a way to Add method....



Where is that command?










share|improve this question



























    1














    In the Nautilus System Browser (Pharo 6) there's a right-click command to Add package... as well as Add class... and even Add protocol..., but I can't find anywhere a way to Add method....



    Where is that command?










    share|improve this question

























      1












      1








      1







      In the Nautilus System Browser (Pharo 6) there's a right-click command to Add package... as well as Add class... and even Add protocol..., but I can't find anywhere a way to Add method....



      Where is that command?










      share|improve this question













      In the Nautilus System Browser (Pharo 6) there's a right-click command to Add package... as well as Add class... and even Add protocol..., but I can't find anywhere a way to Add method....



      Where is that command?







      pharo






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 '18 at 12:33









      Fuhrmanator

      5,07933166




      5,07933166
























          1 Answer
          1






          active

          oldest

          votes


















          2














          In Pharo, adding a method is not as explicit as the other elements. To add a new method:





          1. Select the protocol for the method, and you should see a template in the editor pane:



            messageSelectorAndArgumentNames
            "comment stating purpose of message"

            | temporary variable names |
            statements


          2. Edit this template to make a new method,


          3. Save (Right-click Accept) it using Ctrl-S.


          In fact, any time you change a method's definition (e.g., messageSelectorAndArgumentNames) and save it in the editor (Right-click Accept or Ctrl-S), it will create a new method.



          enter image description here



          For more details, see the section 1.3 of Developing a simple counter document (emphasis is mine):




          Create a method



          Now let us create the accessor methods for the instance variable count. Start
          by selecting the class Counter in a browser, and make sure the you are editing the instance side of the class (i.e., we define methods that will be sent to
          instances) by deselecting the Class side radio button.



          Create a new protocol by bringing the menu of methods protocol list. Select
          the newly created protocol. Then in the bottom pane, the edit field displays
          a method template laying out the default structure of a method. As a general
          hint, double click at the end of or beginning of the text and start typing your
          method. Replace the template with the following method definition:



          count
          "return the current value of the value instance variable"
          ^ count


          This defines a method called count, taking no arguments, having a method
          comment and returning the instance variable count. Then choose accept in
          the menu to compile the method.







          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374761%2fhow-to-add-a-new-method-in-pharo%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            In Pharo, adding a method is not as explicit as the other elements. To add a new method:





            1. Select the protocol for the method, and you should see a template in the editor pane:



              messageSelectorAndArgumentNames
              "comment stating purpose of message"

              | temporary variable names |
              statements


            2. Edit this template to make a new method,


            3. Save (Right-click Accept) it using Ctrl-S.


            In fact, any time you change a method's definition (e.g., messageSelectorAndArgumentNames) and save it in the editor (Right-click Accept or Ctrl-S), it will create a new method.



            enter image description here



            For more details, see the section 1.3 of Developing a simple counter document (emphasis is mine):




            Create a method



            Now let us create the accessor methods for the instance variable count. Start
            by selecting the class Counter in a browser, and make sure the you are editing the instance side of the class (i.e., we define methods that will be sent to
            instances) by deselecting the Class side radio button.



            Create a new protocol by bringing the menu of methods protocol list. Select
            the newly created protocol. Then in the bottom pane, the edit field displays
            a method template laying out the default structure of a method. As a general
            hint, double click at the end of or beginning of the text and start typing your
            method. Replace the template with the following method definition:



            count
            "return the current value of the value instance variable"
            ^ count


            This defines a method called count, taking no arguments, having a method
            comment and returning the instance variable count. Then choose accept in
            the menu to compile the method.







            share|improve this answer




























              2














              In Pharo, adding a method is not as explicit as the other elements. To add a new method:





              1. Select the protocol for the method, and you should see a template in the editor pane:



                messageSelectorAndArgumentNames
                "comment stating purpose of message"

                | temporary variable names |
                statements


              2. Edit this template to make a new method,


              3. Save (Right-click Accept) it using Ctrl-S.


              In fact, any time you change a method's definition (e.g., messageSelectorAndArgumentNames) and save it in the editor (Right-click Accept or Ctrl-S), it will create a new method.



              enter image description here



              For more details, see the section 1.3 of Developing a simple counter document (emphasis is mine):




              Create a method



              Now let us create the accessor methods for the instance variable count. Start
              by selecting the class Counter in a browser, and make sure the you are editing the instance side of the class (i.e., we define methods that will be sent to
              instances) by deselecting the Class side radio button.



              Create a new protocol by bringing the menu of methods protocol list. Select
              the newly created protocol. Then in the bottom pane, the edit field displays
              a method template laying out the default structure of a method. As a general
              hint, double click at the end of or beginning of the text and start typing your
              method. Replace the template with the following method definition:



              count
              "return the current value of the value instance variable"
              ^ count


              This defines a method called count, taking no arguments, having a method
              comment and returning the instance variable count. Then choose accept in
              the menu to compile the method.







              share|improve this answer


























                2












                2








                2






                In Pharo, adding a method is not as explicit as the other elements. To add a new method:





                1. Select the protocol for the method, and you should see a template in the editor pane:



                  messageSelectorAndArgumentNames
                  "comment stating purpose of message"

                  | temporary variable names |
                  statements


                2. Edit this template to make a new method,


                3. Save (Right-click Accept) it using Ctrl-S.


                In fact, any time you change a method's definition (e.g., messageSelectorAndArgumentNames) and save it in the editor (Right-click Accept or Ctrl-S), it will create a new method.



                enter image description here



                For more details, see the section 1.3 of Developing a simple counter document (emphasis is mine):




                Create a method



                Now let us create the accessor methods for the instance variable count. Start
                by selecting the class Counter in a browser, and make sure the you are editing the instance side of the class (i.e., we define methods that will be sent to
                instances) by deselecting the Class side radio button.



                Create a new protocol by bringing the menu of methods protocol list. Select
                the newly created protocol. Then in the bottom pane, the edit field displays
                a method template laying out the default structure of a method. As a general
                hint, double click at the end of or beginning of the text and start typing your
                method. Replace the template with the following method definition:



                count
                "return the current value of the value instance variable"
                ^ count


                This defines a method called count, taking no arguments, having a method
                comment and returning the instance variable count. Then choose accept in
                the menu to compile the method.







                share|improve this answer














                In Pharo, adding a method is not as explicit as the other elements. To add a new method:





                1. Select the protocol for the method, and you should see a template in the editor pane:



                  messageSelectorAndArgumentNames
                  "comment stating purpose of message"

                  | temporary variable names |
                  statements


                2. Edit this template to make a new method,


                3. Save (Right-click Accept) it using Ctrl-S.


                In fact, any time you change a method's definition (e.g., messageSelectorAndArgumentNames) and save it in the editor (Right-click Accept or Ctrl-S), it will create a new method.



                enter image description here



                For more details, see the section 1.3 of Developing a simple counter document (emphasis is mine):




                Create a method



                Now let us create the accessor methods for the instance variable count. Start
                by selecting the class Counter in a browser, and make sure the you are editing the instance side of the class (i.e., we define methods that will be sent to
                instances) by deselecting the Class side radio button.



                Create a new protocol by bringing the menu of methods protocol list. Select
                the newly created protocol. Then in the bottom pane, the edit field displays
                a method template laying out the default structure of a method. As a general
                hint, double click at the end of or beginning of the text and start typing your
                method. Replace the template with the following method definition:



                count
                "return the current value of the value instance variable"
                ^ count


                This defines a method called count, taking no arguments, having a method
                comment and returning the instance variable count. Then choose accept in
                the menu to compile the method.








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 20 '18 at 12:44

























                answered Nov 19 '18 at 12:33









                Fuhrmanator

                5,07933166




                5,07933166






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374761%2fhow-to-add-a-new-method-in-pharo%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    MongoDB - Not Authorized To Execute Command

                    How to fix TextFormField cause rebuild widget in Flutter

                    Npm cannot find a required file even through it is in the searched directory