Can I create an Apex.Stack for any type?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
4
down vote

favorite












Can I create an Apex.Stack for any type?



If I will do:



Apex.Stack stackForIds = new Apex.Stack();


Then I am able to put id values in such a stack:



stackForIds.push(anId);


Here is how I tried to put an SObject into my stack:



Apex.Stack<SObject> stackForSObjects= new Apex.Stack<SObject>();
stackForSObjects.push(new SObject(Id = anId));


And it did not work out. I am getting an error:




Cannot resolve symbol Apex.Stack<SObject>




enter image description here



There seems to be no documentation on the Apex.Stack, so I would be grateful for it. Otherwise I am asking for help to figure out whether or not Apex.Stack is able to work with an arbitrary type.










share|improve this question





























    up vote
    4
    down vote

    favorite












    Can I create an Apex.Stack for any type?



    If I will do:



    Apex.Stack stackForIds = new Apex.Stack();


    Then I am able to put id values in such a stack:



    stackForIds.push(anId);


    Here is how I tried to put an SObject into my stack:



    Apex.Stack<SObject> stackForSObjects= new Apex.Stack<SObject>();
    stackForSObjects.push(new SObject(Id = anId));


    And it did not work out. I am getting an error:




    Cannot resolve symbol Apex.Stack<SObject>




    enter image description here



    There seems to be no documentation on the Apex.Stack, so I would be grateful for it. Otherwise I am asking for help to figure out whether or not Apex.Stack is able to work with an arbitrary type.










    share|improve this question

























      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      Can I create an Apex.Stack for any type?



      If I will do:



      Apex.Stack stackForIds = new Apex.Stack();


      Then I am able to put id values in such a stack:



      stackForIds.push(anId);


      Here is how I tried to put an SObject into my stack:



      Apex.Stack<SObject> stackForSObjects= new Apex.Stack<SObject>();
      stackForSObjects.push(new SObject(Id = anId));


      And it did not work out. I am getting an error:




      Cannot resolve symbol Apex.Stack<SObject>




      enter image description here



      There seems to be no documentation on the Apex.Stack, so I would be grateful for it. Otherwise I am asking for help to figure out whether or not Apex.Stack is able to work with an arbitrary type.










      share|improve this question















      Can I create an Apex.Stack for any type?



      If I will do:



      Apex.Stack stackForIds = new Apex.Stack();


      Then I am able to put id values in such a stack:



      stackForIds.push(anId);


      Here is how I tried to put an SObject into my stack:



      Apex.Stack<SObject> stackForSObjects= new Apex.Stack<SObject>();
      stackForSObjects.push(new SObject(Id = anId));


      And it did not work out. I am getting an error:




      Cannot resolve symbol Apex.Stack<SObject>




      enter image description here



      There seems to be no documentation on the Apex.Stack, so I would be grateful for it. Otherwise I am asking for help to figure out whether or not Apex.Stack is able to work with an arbitrary type.







      apex






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 9 at 14:03









      Adrian Larson♦

      101k19107226




      101k19107226










      asked Sep 9 at 9:20









      iloveseven

      49516




      49516




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          As AFIK there is no such class in the platform's API, look in your own code base for a class called Apex that has an inner class called Stack.



          If you want to support other types, you will have to add additional methods for those and generalize the implementation. Other languages include better mechanisms for this situation - see e.g. Java's Generic Types.



          Though as this Apex.Stack code probably does very little, changing the method signatures and implementation to use Object rather than Id would probably be the best way to go as then all types would be supported. But casts would be needed when values are popped.






          share|improve this answer






















          • Oh. That explains why I was not able to find the documentation on Apex.Stack.
            – iloveseven
            Sep 9 at 11:02






          • 4




            @iloveseven Yeah I'm a bit surprised you can even create a class called Apex as it makes you think it is a platform feature.
            – Keith C
            Sep 9 at 11:37










          • Apex is not a recognised keyword, so I belive it should not cause compilation error. Which makes sense.
            – Pranay Jaiswal
            Sep 9 at 11:50











          • @PranayJaiswal You mean a reserved word ?
            – Bennie
            Sep 9 at 13:37

















          up vote
          0
          down vote













          The Apex.Stack class has known limitations and bugs, which is why it was never formally released in the documentation. Do not use it if you care about the stability of your code.






          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "459"
            ;
            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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f231754%2fcan-i-create-an-apex-stack-for-any-type%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            5
            down vote



            accepted










            As AFIK there is no such class in the platform's API, look in your own code base for a class called Apex that has an inner class called Stack.



            If you want to support other types, you will have to add additional methods for those and generalize the implementation. Other languages include better mechanisms for this situation - see e.g. Java's Generic Types.



            Though as this Apex.Stack code probably does very little, changing the method signatures and implementation to use Object rather than Id would probably be the best way to go as then all types would be supported. But casts would be needed when values are popped.






            share|improve this answer






















            • Oh. That explains why I was not able to find the documentation on Apex.Stack.
              – iloveseven
              Sep 9 at 11:02






            • 4




              @iloveseven Yeah I'm a bit surprised you can even create a class called Apex as it makes you think it is a platform feature.
              – Keith C
              Sep 9 at 11:37










            • Apex is not a recognised keyword, so I belive it should not cause compilation error. Which makes sense.
              – Pranay Jaiswal
              Sep 9 at 11:50











            • @PranayJaiswal You mean a reserved word ?
              – Bennie
              Sep 9 at 13:37














            up vote
            5
            down vote



            accepted










            As AFIK there is no such class in the platform's API, look in your own code base for a class called Apex that has an inner class called Stack.



            If you want to support other types, you will have to add additional methods for those and generalize the implementation. Other languages include better mechanisms for this situation - see e.g. Java's Generic Types.



            Though as this Apex.Stack code probably does very little, changing the method signatures and implementation to use Object rather than Id would probably be the best way to go as then all types would be supported. But casts would be needed when values are popped.






            share|improve this answer






















            • Oh. That explains why I was not able to find the documentation on Apex.Stack.
              – iloveseven
              Sep 9 at 11:02






            • 4




              @iloveseven Yeah I'm a bit surprised you can even create a class called Apex as it makes you think it is a platform feature.
              – Keith C
              Sep 9 at 11:37










            • Apex is not a recognised keyword, so I belive it should not cause compilation error. Which makes sense.
              – Pranay Jaiswal
              Sep 9 at 11:50











            • @PranayJaiswal You mean a reserved word ?
              – Bennie
              Sep 9 at 13:37












            up vote
            5
            down vote



            accepted







            up vote
            5
            down vote



            accepted






            As AFIK there is no such class in the platform's API, look in your own code base for a class called Apex that has an inner class called Stack.



            If you want to support other types, you will have to add additional methods for those and generalize the implementation. Other languages include better mechanisms for this situation - see e.g. Java's Generic Types.



            Though as this Apex.Stack code probably does very little, changing the method signatures and implementation to use Object rather than Id would probably be the best way to go as then all types would be supported. But casts would be needed when values are popped.






            share|improve this answer














            As AFIK there is no such class in the platform's API, look in your own code base for a class called Apex that has an inner class called Stack.



            If you want to support other types, you will have to add additional methods for those and generalize the implementation. Other languages include better mechanisms for this situation - see e.g. Java's Generic Types.



            Though as this Apex.Stack code probably does very little, changing the method signatures and implementation to use Object rather than Id would probably be the best way to go as then all types would be supported. But casts would be needed when values are popped.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Sep 9 at 10:31

























            answered Sep 9 at 10:25









            Keith C

            91.2k1084189




            91.2k1084189











            • Oh. That explains why I was not able to find the documentation on Apex.Stack.
              – iloveseven
              Sep 9 at 11:02






            • 4




              @iloveseven Yeah I'm a bit surprised you can even create a class called Apex as it makes you think it is a platform feature.
              – Keith C
              Sep 9 at 11:37










            • Apex is not a recognised keyword, so I belive it should not cause compilation error. Which makes sense.
              – Pranay Jaiswal
              Sep 9 at 11:50











            • @PranayJaiswal You mean a reserved word ?
              – Bennie
              Sep 9 at 13:37
















            • Oh. That explains why I was not able to find the documentation on Apex.Stack.
              – iloveseven
              Sep 9 at 11:02






            • 4




              @iloveseven Yeah I'm a bit surprised you can even create a class called Apex as it makes you think it is a platform feature.
              – Keith C
              Sep 9 at 11:37










            • Apex is not a recognised keyword, so I belive it should not cause compilation error. Which makes sense.
              – Pranay Jaiswal
              Sep 9 at 11:50











            • @PranayJaiswal You mean a reserved word ?
              – Bennie
              Sep 9 at 13:37















            Oh. That explains why I was not able to find the documentation on Apex.Stack.
            – iloveseven
            Sep 9 at 11:02




            Oh. That explains why I was not able to find the documentation on Apex.Stack.
            – iloveseven
            Sep 9 at 11:02




            4




            4




            @iloveseven Yeah I'm a bit surprised you can even create a class called Apex as it makes you think it is a platform feature.
            – Keith C
            Sep 9 at 11:37




            @iloveseven Yeah I'm a bit surprised you can even create a class called Apex as it makes you think it is a platform feature.
            – Keith C
            Sep 9 at 11:37












            Apex is not a recognised keyword, so I belive it should not cause compilation error. Which makes sense.
            – Pranay Jaiswal
            Sep 9 at 11:50





            Apex is not a recognised keyword, so I belive it should not cause compilation error. Which makes sense.
            – Pranay Jaiswal
            Sep 9 at 11:50













            @PranayJaiswal You mean a reserved word ?
            – Bennie
            Sep 9 at 13:37




            @PranayJaiswal You mean a reserved word ?
            – Bennie
            Sep 9 at 13:37












            up vote
            0
            down vote













            The Apex.Stack class has known limitations and bugs, which is why it was never formally released in the documentation. Do not use it if you care about the stability of your code.






            share|improve this answer
























              up vote
              0
              down vote













              The Apex.Stack class has known limitations and bugs, which is why it was never formally released in the documentation. Do not use it if you care about the stability of your code.






              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                The Apex.Stack class has known limitations and bugs, which is why it was never formally released in the documentation. Do not use it if you care about the stability of your code.






                share|improve this answer












                The Apex.Stack class has known limitations and bugs, which is why it was never formally released in the documentation. Do not use it if you care about the stability of your code.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Sep 10 at 0:02









                sfdcfox

                229k10176390




                229k10176390



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f231754%2fcan-i-create-an-apex-stack-for-any-type%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    這個網誌中的熱門文章

                    How to combine Bézier curves to a surface?

                    Why am i infinitely getting the same tweet with the Twitter Search API?

                    Carbon dioxide