Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

8
  • It's not so much about hiding the array, more about getting those add/remove functions out of the class's context and into the variable context... Not sure what the terms are. Instead of MyClass.addPost I want to know if I can have MyClass.post.add() while still being able to have a default value returned for MyClass.post I am beginning to think it's not possible, but thought I'd ask.
    – xon52
    Commented Jun 5, 2018 at 1:48
  • So you want the same value no matter what instance of the class right? There's a way to do that.
    – Eddie D
    Commented Jun 5, 2018 at 1:49
  • sounded like static variable? stackoverflow.com/questions/1535631/…
    – Isaac
    Commented Jun 5, 2018 at 1:53
  • No, not static. The array is instance dependent.
    – xon52
    Commented Jun 5, 2018 at 1:56
  • 1
    Figured out a way to do it by extending the Array class.
    – Eddie D
    Commented Jun 5, 2018 at 2:06